PIC BASIC TLC5940 code


Results 1 to 10 of 10

Threaded View

  1. #10
    Join Date
    Mar 2010
    Location
    Minnesota, USA
    Posts
    41


    Did you find this post helpful? Yes | No

    Default My code works but it flickers because my GSCLK is too slow HELP

    How can I get this to stop flickering? It flickers even at 16MHz. With 4 MHz it taks the GSCLK about 250 ms to complete making all the GSDATA that are 0's really stand out causing a flicker.

    Is there some other way I could do the GSCLK so I am not just turning the GSCLK pin H/L 4096 times?

    Code:
    ANSEL = 0 'ALL DIGITAL
    CMCON = 7 'COMPARATORS OFF
    TRISA = %00000000
    TRISB = %00000000
    
    DPIN        CON     7
    SCLK        CON     6
    XLAT        CON     5
    BLANK       CON     2
    VPRG        var     PORTA.0
    DCPRG       var     PORTA.2
    
    
    C1          var     byte
    C2          var     byte
    C3          var     word
    
    GSDATA      var     word
    Code:
    GOSUB preset
    '***************************************************
    '*                    Main Loop                    *
    '***************************************************
    LOOP:
    FOR GSDATA = 4095 TO 0 STEP -16
        gosub setgs
        gosub lightemup
    NEXT
    FOR GSDATA = 4095 TO 0 STEP 16
        gosub setgs
        gosub lightemup
    NEXT
    goto LOOP
    '***************************************************
    '*                      Set GS                     *
    '***************************************************
    SETGS:
    for C1 = 0 to 15                        ' for 16 outputs
        shiftout dpin,sclk,1,[GSDATA\12]    ' shift out 12 bit GS Data
    next
        PORTB = %00100000                   ' high xlat
        PORTB = %00000000                   ' low xlat
    return
    '***************************************************
    '*                   LIGHT EM UP                   *
    '***************************************************
    LIGHTEMUP:
    PORTB = %00000100                       ' high blank
    PORTB = %00000000                       ' All outputs = ON 
    for C3 = 0 to 4095                      ' Generate 4096 GSCLK pulses 
        PORTA = %00001000                   ' GSCLK HIGH 
        PORTA = %00000000                   ' GSCLK LOW 
    next
    return
    '***************************************************
    '*                      Preset                     *
    '***************************************************
    PRESET:
    'HIGH DCPRG
    HIGH VPRG                               ' Put into dot correction mode
    HIGH blank                              ' All outputs OFF
    low dpin                                ' Starts dot correction
    low xlat
    For C1 = 0 to 15                        ' 16 Ports
        shiftout dpin,sclk,1,[%111111\6]    ' 6 bits of Dot Correction per port
    next
    high xlat                               ' Latch bits into dot correct register
    low xlat
    low VPRG                                ' Enter GS Mode
    for C1 = 0 to 15
        for C2 = 0 to 11
            shiftout dpin,sclk,1,[%111111111111\12] 
        next
    next
    high xlat                               ' Latch bits into GS register 
    low xlat
    high SCLK                               '193rd CLK pulse
    LOW SCLK
    low blank                               ' All outputs = ON 
    return
    NOTE: This code is basically the same as the above Adruno code but I have a different fade routine. The above code used direct PORT addressing for GSCLK like I did but they were using an 8MHz Adruno for their project and it worked fine. I don't understand why this will not work in PBP with 16 MHz running the show.
    Last edited by wolwil; - 8th May 2010 at 21:23.

Similar Threads

  1. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  2. pic Basic Pro 2.50a & debug statement
    By Phil Moore in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 17th March 2008, 09:41
  3. PIC BASIC or PIC BASIC PRO
    By kirkmans in forum USB
    Replies: 3
    Last Post: - 20th April 2007, 00:52
  4. Replies: 5
    Last Post: - 17th January 2006, 19:26
  5. Help with MPASM and PIC Basic
    By johngb in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 21st February 2003, 13:07

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