Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Soft uart with pic12f1501

Status
Not open for further replies.

anjalimidhuna

Member level 3
Member level 3
Joined
Jan 4, 2014
Messages
62
Helped
2
Reputation
4
Reaction score
2
Trophy points
8
Location
india
Visit site
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.
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;

    }
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top