vedo35
Member
Hello friends i am trying to learn led drive with STP16CP05 spi led driver. I did a lot of thing but i coudnt success to led on-of or blink. I am using CCS. Anybody can help for me? Here is my source code. Thanks for all your help or idea.
C:
#include <16F887.h>
#FUSES NOWDT
#FUSES NOMCLR
#FUSES NOCPD
#FUSES NOBROWNOUT
#FUSES XT
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
/////////////////////////////////////////////////////////////////////////////////
#define SDI PIN_C0
#define CLK PIN_C1
#define LE PIN_C2
int i, data;
void counting()
{
output_low(SDI);
for (i=0; i<data; ++i)
{
output_low(CLK);
delay_ms(100);
output_high(CLK);
delay_ms(100);
}
printf("%2x", data);
}
void Send16Bit(unsigned int16 data16bit )
{
unsigned int16 i;
for(i=0x8000;i>0;i>>=1)
{
if(i&data16bit)output_high(SDI);
else output_low(SDI);
output_high(CLK);
delay_us(1);
output_low(CLK);
}
output_high(LE);
delay_us(5);
output_low(LE);
}
unsigned int16 led_data;
led_data(b01000100000000001);
Send16Bit(led_data );
void Main()
{
output_high(SDI);
delay_ms(100);
output_high(CLK);
delay_ms(100);
output_low(CLK);
while(true)
{
if(kbhit())
{
data=getc();
counting();
}
}
}
Last edited by a moderator: