Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/16/00 17:34
Read: times


 
#6559 - RE: Communication via UART in C
Anders,
Here is a start a serial communications in c. This isn't complete and I don't garauntee it to be bug free, but it is a good start. You should be able to get the idea.

Allen


#define DELIMITER 'some character'
extern unsigned char Rcv_Buffer[25];
extern unsigned char Xmt_Buffer[25];
extern unsigned char Rbuff_Ptr;
extern unsigned char Tbuff_Ptr;
extern unsigned char Message_Length;
extern bit Message_Recvd;

//where x is the serial interrupt number
serial_isr() interrupt x
{
if (RI)
{
Rcv_Buffer[Rbuff_Ptr] == SBUF;
Rbuff_Ptr++;

if(Rcv_Buffer[Rbuff_Ptr] == DELIMITER)
{
//Set this flag to tell main
//to process message. Message
//function should reset flag
//and message length
Message_Recvd = 1;
Message_Length = Rbuff_Ptr;
Rbuff_Ptr = 0;
}

}//end if(RI)

if(TI)
{
//Send out a message from an array
SBUF = Xmt_Buffer[Tbuff_Ptr];
Tbuff_Ptr = 0;
//check for end of message
//you can figure out how.

}//end if(TI)
}//end serial_isr

List of 8 messages in thread
TopicAuthorDate
Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      
RE: Communication via UART in C            01/01/70 00:00      

Back to Subject List