[picbasic] pic18F2550 -> TLC5940

Alleen berichten met de trefwoorden “breadboard” worden getoond. Alle berichten tonen

Hallo,

Al enige tijd ben ik aan het proberen om de TLC5940NT werkend te krijgen mbv een pic.
Bij toeval heeft het onderstaande schema een keer gewerkt, maar nu ik alles van breadboard af en op printjes geetst heb doet hij het niet meer. Alle led's zouden aan moeten faden en daarna allemaal uit faden. Echter, ze branden alleen maar volop aan (ook als ik GSData = 0 instel).
Wie kan/wil mij hierbij helpen?

Schema (verspreid over 2 PCB's):
http://a.imageshack.us/img714/1053/rgber.th.jpg

Programma:

pic basic code:

'****************************************************************
'*  Name    : RGB.BAS                                           *
'*  Author  :                                  *
'*  Notice  : Copyright (c) 2010             *
'*          : All Rights Reserved                               *
'*  Date    : 24-5-2010                                         *
'*  Version : 1.0                                               *
'*  Notes   : deels gepikt van:                                 *
'*          : http://www.picbasic.co.uk/forum/archive/index.php/t-11603.html *
'****************************************************************
Device 18F2550
Xtal 20

Config_Start
   PLLDIV = 5 ; Divide by 5 (20 MHz oscillator input;4=8mhz)
   CPUDIV = OSC1_PLL2 ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
   FOSC = HS ; HS oscillator, HS used by USB
   PWRT = On ; PWRT enabled
   BOR = OFF ; Brown-out Reset disabled in hardware and software
   WDT = OFF ; HW Disabled - SW Controlled
   WDTPS = 1 ; 1:1
   MCLRE = On ; RE3 input pin enabled; MCLR disabled
   STVREN = On ; Stack full/underflow will cause Reset
   LVP = OFF ; Single-Supply ICSP disabled
   XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
   Debug = OFF ; Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
   CP0 = OFF ; Block 0 (000800-001FFFh) not code-protected
   CP1 = OFF ; Block 1 (002000-003FFFh) not code-protected
   CP2 = OFF ; Block 2 (004000-005FFFh) not code-protected
   CP3 = OFF ; Block 3 (006000-007FFFh) not code-protected
   CPB = OFF ; Boot block (000000-0007FFh) not code-protected
   CPD = OFF ; Data EEPROM not code-protected
   WRT0 = OFF ; Block 0 (000800-001FFFh) not write-protected
   WRT1 = OFF ; Block 1 (002000-003FFFh) not write-protected
   WRT2 = OFF ; Block 2 (004000-005FFFh) not write-protected
   WRT3 = OFF ; Block 3 (006000-007FFFh) not write-protected
   WRTB = OFF ; Boot block (000000-0007FFh) not write-protected
   WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
   WRTD = OFF ; Data EEPROM not write-protected
   EBTR0 = OFF ; Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
   EBTR1 = OFF ; Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
   EBTR2 = OFF ; Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
   EBTR3 = OFF ; Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
   EBTRB = OFF ; Boot block (000000-0oit 007FFh) not protected from table reads executed in other blocks
Config_End

All_Digital TRUE
PortB_Pullups On
        ;76543210         1=input&aan, 0=output&uit
TRISA = %00000000
TRISB = %00001100
TRISC = %00000000

PORTA = %00000000
PORTB = %00000000
PORTC = %00000000

Symbol BLANK    PORTA.1; 
Symbol Mosi     PORTB.4;
Symbol Miso     PORTB.3; 
Symbol SCLK     PORTC.0; 
Symbol MLED     PORTA.0;
Symbol XLAT     PORTC.1;
Symbol VPRG     PORTA.3;
Symbol DCPRG    PORTA.4;
Symbol GSCLK    PORTA.2;
Symbol XERR     PORTB.2;

Dim FirstCycleFlag As Byte
Dim GSDATA As Word

Dim n As Byte
Dim c1 As Byte
Dim c2 As Byte

GoSub PRESET
'***************************************************
'*                    Main Loop                    *
'***************************************************
LOOP:

    Toggle MLED
    For GSDATA = 0 To 4095 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 (n*16 - 1) ' for n*16 outputs
        SHOut Mosi,SCLK,1,[GSDATA\12] ' shift out 12 bit GS Data
    Next 
    GoSub pulseXLAT
    If FirstCycleFlag = 1 Then GoSub pulseSCLK
    FirstCycleFlag = 0
    Return
'***************************************************
'*                  LIGHT EM UP                    *
'***************************************************
LIGHTEMUP:

    GoSub pulseBLANK
    For c2 = 0 To 4095 ' Generate 4096 GSCLK pulses 
        GoSub pulseGSCLK
    Next
    Return
'***************************************************
'*                   pulse SCLK                    *
'***************************************************
pulseSCLK:

    High SCLK
    Low SCLK
    Return    
'***************************************************
'*                   pulse BLANK                   *
'***************************************************
pulseBLANK:

    High BLANK
    Low BLANK
    Return    
'***************************************************
'*                   pulse XLAT                    *
'***************************************************
pulseXLAT:

    High XLAT
    Low XLAT
    Return   
'***************************************************
'*                   pulse GSCLK                   *
'***************************************************
pulseGSCLK:

    High GSCLK
    Low GSCLK
    Return 
'***************************************************
'*                    preset                       *
'***************************************************
PRESET:

    n = 3 ;3 TLC5940NT's in serie / daisy chain
    
    'DC in register gooien
    High DCPRG
    High VPRG ' Put into dot correction mode
    High BLANK ' All outputs OFF
    For c1 = 0 To (n*16 - 1) ' n*16 Ports
        SHOut Mosi,SCLK,1,[%111111\6] ' 6 bits of Dot Correction per port
    Next
    GoSub pulseXLAT ' Latch bits into dot correct register
    'niet in EEProm opslaan omdat er geen 22V aanwezig is
    'GS mode
    Low VPRG
    Low BLANK
    FirstCycleFlag = 1
    Return