23rd Oct 2007

For the LED circuit, we used this LED driver TLC5940 that needs the SPI protocol to program the serial communication between PIC and the LED driver. I wrote the program to test the output from the SDO pin of the PIC.

//void LED_driver(){
output_low(BLANK);
output_low(XLAT);

spi_write(0x00); //channel 15
spi_write(0x0a); //channel 14
spi_write(0x10); //channel 13
spi_write(0x32); //channel 12
spi_write(0x0a); //channel 11
spi_write(0x10); //channel 10
spi_write(0x32); //channel 9
spi_write(0x0a); //channel 8
spi_write(0x10); //channel 7
spi_write(0x32); //channel 6
spi_write(0x0a); //channel 5
spi_write(0x10); //channel 4
spi_write(0x32); //channel 3
spi_write(0x0a); //channel 2
spi_write(0x10); //channel 1
spi_write(0x32); //channel 0

output_high(XLAT); //??how to make XLAT only pulse
delay_us(30000); //30ns
output_low(XLAT);
output_high(PIN_B7); //let the first row able to light up
}

void main()
{
set_tris_b(0x20); //RB7 output 00100000
set_tris_d(0x00); //00000000
output_low(PIN_B7);
output_low(PIN_B6);
output_b(0b00000000);

output_high(PIN_B4);
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_64);

while(true){
delay_ms(5000);
LED_driver();
}
}//

Then I tested the output from the SDO pin on the PIC, it shows the following graph:

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License