vedo35
Newbie level 4
- Joined
- Sep 18, 2009
- Messages
- 6
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,283
- Location
- netherlands
- Activity points
- 1,318
Hi friends since long time i was busy with STP16CP05 led driver ic. Its a serial in led driver with 16 bit output. I made myself development board for learning. Codes work ok but now next step project is to make blinking leds or some leds are blinking some are continious burning. which codes i need? and to which line i have to put that code?
My example code:
#include <16F877.h>
#FUSES NOWDT
#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;
void Main()
{
output_high(SDI);
delay_ms(100);
output_high(CLK);
delay_ms(100);
output_low(CLK);
while(true)
{
led_data = 0x80BF;
Send16Bit(led_data );
if(kbhit())
{
data=getc();
counting();
}
}
}
My example code:
#include <16F877.h>
#FUSES NOWDT
#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;
void Main()
{
output_high(SDI);
delay_ms(100);
output_high(CLK);
delay_ms(100);
output_low(CLK);
while(true)
{
led_data = 0x80BF;
Send16Bit(led_data );
if(kbhit())
{
data=getc();
counting();
}
}
}