anjalimidhuna
Member level 3
- Joined
- Jan 4, 2014
- Messages
- 62
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 8
- Location
- india
- Activity points
- 358
i am trying to send a data using soft uart with pic12f1501.i wrote the program as follows.while checking the output using pickit2 UART tool, it doesn't receive any data.
plz correct my code.
and the isr
plz correct my code.
Code:
void main()
{
char i;
OSCCON=0b01111010;
while(HFIOFS==0);
portinit();
intrinit();
timer0init();
pwminit();
flag1=0;
flag2=0;
duty=0;
while(1)
{
if(flag1==1)
{
__delay_ms(30);
ID_LED=0;
flag1=0;
}
if(flag2==1)
{
for(i=0;i<DEVICE_ID;i++)
{
ID_LED=1;
__delay_ms(300);
ID_LED=0;
__delay_ms(300);
}
flag2=0;
}
PWM1DCH=(duty>>2)&0x3F;
PWM1DCL=(duty<<6)&0xC0;
}
}
and the isr
Code:
void interrupt isr() // ISR
{
if(IOCAF5==1)
{
datavalue=UARTread();
asm("nop");
asm("nop");
asm("nop");
asm("nop");
UARTwrite(datavalue);
asm("nop");
asm("nop");
asm("nop");
asm("nop");
if(RA3==1)
{
update(datavalue);
flag1=1;
}
else
{
DEVICE_ID=(datavalue>>4&0x0F);
flag2=1;
}
IOCAF5=0;
}
}