Sancho1977
New Member
Hi all, I am biginner about the USART.
I have a problem with the complier,XC8. Though I tried to include the header file called as usart.h at several times, I could not complete it.
Someone , help me about teaching me a code as macro.
I need also void(unsigned char?) putsUSART( char * buffer, char length 20){}
I could get a code on web about void getsUSART like this.
void getsUSART(char *buffer, unsigned char len)
{
char i; // Length counter
unsigned char data;
for(i=0;i<len;i++) // Only retrieve len characters
{
while(RCIF==0);// Wait for data to be received
data = RCREG; // Get a character from the USART
// and save in the string
*buffer = data;
buffer++; // Increment the string pointer
}
}
P.S. As I do not have a Debugger for this program, I do not want to use a wrong code for it.
↓ could the following code be used for my requirement?
void putsUSART_( unsigned char *buffer)
{
while( *buffer>0) {
TXREG=*buffer++;
}
}
Thanks in advance
I have a problem with the complier,XC8. Though I tried to include the header file called as usart.h at several times, I could not complete it.
Someone , help me about teaching me a code as macro.
I need also void(unsigned char?) putsUSART( char * buffer, char length 20){}
I could get a code on web about void getsUSART like this.
void getsUSART(char *buffer, unsigned char len)
{
char i; // Length counter
unsigned char data;
for(i=0;i<len;i++) // Only retrieve len characters
{
while(RCIF==0);// Wait for data to be received
data = RCREG; // Get a character from the USART
// and save in the string
*buffer = data;
buffer++; // Increment the string pointer
}
}
P.S. As I do not have a Debugger for this program, I do not want to use a wrong code for it.
↓ could the following code be used for my requirement?
void putsUSART_( unsigned char *buffer)
{
while( *buffer>0) {
TXREG=*buffer++;
}
}
Thanks in advance
Last edited: