Visualize Clockout


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2006
    Location
    brooklyn
    Posts
    33

    Default Visualize Clockout

    hi-ho,

    been bouncing around. i'd like to get the PIC to control a TLC5940 PWM controller for LEDs and whatnot. i have a grip on how the chip works, and how to format the data to its registers, but the 5940 requires a clock signal to time the PWM. [4096 cycles, a little handshake, 4096 more cycles...] i'm thinking 'hey, there's that TMR1 right there. why not, you know...' so i'm just ramping up on getting the CCP and TMR1 to talk to eachother. part of my solution for timing the PWM is to use the INTRC (clockout) configuration. i'm running a 16F88 and have gotten some good results with my test code, and i want to visualize the clockout ont RA6. so, i went ahead and put an LED on it. it gives a little blink when the program starts up, but then nothing. what's going on? am i asking too much of the little OSC2? i even put my multimeter on it, thinking that i would at least see some +V... nuthin.
    simple code below. sorry darryl, i'm not using your amazing thing.
    as a side note, the software toggle of B.4 goes on and off like you read about. but the mulitplexed B.3 just sits there sorta 'on' even though i'm setting it low in the isr.


    16F88, INTRC clockout, disable BOR due to 3V3


    OSCCON = %01110110 '8MHz INTERNAL OSCILLATOR
    ANSEL = %00000000 'MAKE PortA PINS ALL DIGITAL
    TRISB = %00000000

    LED VAR PortB.4
    LED1 VAR PortB.3

    T1CON = %00100001 'ENABLE TIMRE ONE, PRESCALE 1:1, USE INTERNAL CLK
    INTCON = %11000000 'ENABLE GLOBAL INT, ENABLE PERIPHERAL INT,
    PIE1 = %00000100 'ENABLE CCP1 INT
    CCP1CON = %00001000 'COMPARE MODE, SET OUTPUT ON MATCH

    CCPR1L = %00000000 'SET CCP REGISTER TO 4069
    CCPR1H = %00010000

    on interrupt goto ISP


    Main:
    PAUSE 1
    GOTO Main

    DISABLE
    ISP:
    TOGGLE LED
    LOW led1
    PIR1.2 = 0
    TMR1H = 0
    TMR1L = 0
    RESUME
    ENABLE

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Trying to drive an LED with OSC2 out is probably not going to work, as it's not designed to
    drive LEDs. It's a low-current clock output. You might get by with applying OSC2 out to the
    base of a transistor, but I've never tried it.

    And your multi-meter may not be fast enough to keep up with a 2MHz pulse out on OSC2.

    An LED turned ON/OFF at 2MHz will most likely appear to be dimly lit all the time. 2MHz is
    pretty quick.

    Your comment for TIMER1 prescaler is wrong. You actually have the prescaler set to 1:4,
    and your comment on the value of CCPR1 is wrong too. It should be 4096 VS 4069.

    If you want to see the LEDs blink, you're going to need a lot more time between interrupts.

    Try something like this;
    Code:
    @ DEVICE INTRC_OSC_CLKOUT, LVP_OFF, WDT_OFF, MCLR_OFF, BOD_OFF, CCPMX_ON, PWRT_ON
    
    OSCCON = %00010000 ' 125kHz INTERNAL OSCILLATOR
    ANSEL = %00000000  ' MAKE PortA PINS ALL DIGITAL
    PORTB = 0          ' ALL CLEAR AT POR
    TRISB = %00000000
    
    LED VAR PortB.4
    LED1 VAR PortB.3
    
    T1CON = %00110001   ' ENABLE TIMER1, PRESCALE 1:8, INTERNAL CLK
    PIE1 = %00000100    ' ENABLE CCP1 INT
    CCP1CON = %00001011 ' COMPARE MODE, AUTO RESET TIMER1
    CCPR1L = %00000000  ' SET CCP REGISTER TO 4096 
    CCPR1H = %00010000  ' 4096*8*32uS = 1.048 seconds toggle rate
    INTCON = %11000000  ' ENABLE GLOBAL INT, ENABLE PERIPHERAL INT.
    
    on interrupt goto ISP
    
    Main:
        @ nop
        GOTO Main
    
    DISABLE
    ISP:
        TOGGLE LED
        TOGGLE LED1
        PIR1.2 = 0
        RESUME
        ENABLE
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Aug 2006
    Location
    brooklyn
    Posts
    33


    Did you find this post helpful? Yes | No

    Default

    bruce, thanks for the reply,

    i may try to put an NPN on OSC2 to see what's up. but i'm more interested in controlling the PWM driver.

    i have the PIC connected to the TLC PWM driver, and it's not working. although it looks like there may be a faint glimmer of life on startup. the thing that gets the PWM going is the GSCLK which i'm attempting to drive with my clockout.
    the DS for the TLC says that minimum pulse time for GSCLK is 16ns. i'm way in range there...

    will try to slow everything down to make sure my timing is matching what the driver needs.
    also thinking about using TMR0 interrupt at 1:16 and toggling my output in the ISR.

    by the way, the pins on the TLC i'm concerned about are
    GSCLK greyscale clock which the chip uses to time the PWM
    BLANK which is toggled at the end/beginning of each 4096 clock period

    i hope the CCP1 can work, cause it's so cool.
    anybody else use this type of LED controller?

Similar Threads

  1. visualize clockout
    By JoelMurphy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th December 2008, 01:09
  2. Replies: 4
    Last Post: - 25th September 2008, 23:50

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts