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.

Serial receive issue on ds33EP256MU810 microcontroller.

Status
Not open for further replies.

mohansaini

Junior Member level 1
Junior Member level 1
Joined
May 22, 2010
Messages
18
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
india
Visit site
Activity points
1,414
Hi all

I am receiving 116 bytes of data on serial port the packet format is fixed as i am receiving Byte0 and Byte1 as '<' and at Byte114 and Byte115
as '>' just to check thet i am receiving a right packet. for that purpose i have written the ISR as

Code:
 void __attribute__ ((interrupt,no_auto_psv)) _U1RXInterrupt (void)
 {
	 static unsigned char count1=0;
	 unsigned char data;
	 data=U1RXREG;
     CalData[count1]=data;
     count1++;
    if((CalData[0]=='<')||(CalData[1]=='<'))        //&&(CalData[114]=='>')&&(CalData[115]=='>'))//we have received right packet now set the flag
        {
         //  CalData[count1++]=data;
             if(((CalData[114]=='>')&&(CalData[115]=='>'))&&(count1>=116))
                {
                 Rxr_Flag=1;
                 count1=0;
                }//Received complete packet 
	     //		else
         //      {
         //        count1=0;   
         //      } //There is something wrong with at the end of the packet
         }			
     else
       {
       count1=0;          //There is some missmatch with thwe data. 
       } 
                                                      
	 IFS0bits.U1RXIF=0;
 }

Now the problem is that if any time length of data is not 116 and Byte0 and Byte1 are '<' the variable count1 will not become 0 so that data will be lost in the next attempt as well.
Please help me out what can i do to make it a very generif function so that it will check the length as well.
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top