Skip to main content
added 256 characters in body
Source Link
AndrejaKo
  • 24k
  • 29
  • 115
  • 192

I'm trying to receive data from PIC18F4680's EUSART (using C18 compiler) module and if I type characters in my terminal emulator slow enough, like one or two characters per second, reception works fine. If I try to transmit several characters quickly it seems that reception stops and only device reset solves the problem. Transmission works fine.

The serial port is running at 115200 b/s and and is set-up using following code (clock is 40 MHz):

OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, f_usart); //f_usart=86 for 40 MHz, 115200, or 1040 for 9600 (but it doesn't work at 9600) baudUSART(BAUD_16_BIT_RATE&BAUD_WAKEUP_OFF&BAUD_AUTO_OFF); 

Here's the code I'm using to read from the port:

 if(DataRdyUSART()) { temp=ReadUSART(); WriteUSART(temp); } 

This code is in a main loop which does some other processing too and sends out data over serial port. I don't expect this piece of code to work too good (I'm just testing to see if loopback works fine), since there's chance that it will miss some characters (or at least I think so, since a new character may be received before there's a chance for old one to be processed), but I didn't expect it to not work at all.

Interesting thing is that if I enable the Rx interrupt and put the exact same code in the ISR, the data can be received at much greater speed. I need to paste text into terminal window in order to cause the problem.

So any ideas what could be happening?

UPDATE

Looks like I'm getting a mix of framing errors and bit overrun errors. I don't think that I can make the data processing in this case much faster to get rid of the overrun errors, so I'll probably slow down the serial port, but I'm not sure what to do about framing errors.

UPDATE 2

At 9600 b/s, I get much less errors, but still if I copy a wall of text into the terminal, I get errors.

UPDATE 3

Looks like my laptop's USB to serial adapter is transmitting at 9900 b/s. Could that be the cause of the problem? If yes, is there anything I can do on the PIC side to help solve the problem other than setting the data rate at 9900 b/s?

I'm trying to receive data from PIC18F4680's EUSART (using C18 compiler) module and if I type characters in my terminal emulator slow enough, like one or two characters per second, reception works fine. If I try to transmit several characters quickly it seems that reception stops and only device reset solves the problem. Transmission works fine.

The serial port is running at 115200 b/s and and is set-up using following code (clock is 40 MHz):

OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, f_usart); //f_usart=86 for 40 MHz, 115200, or 1040 for 9600 (but it doesn't work at 9600) baudUSART(BAUD_16_BIT_RATE&BAUD_WAKEUP_OFF&BAUD_AUTO_OFF); 

Here's the code I'm using to read from the port:

 if(DataRdyUSART()) { temp=ReadUSART(); WriteUSART(temp); } 

This code is in a main loop which does some other processing too and sends out data over serial port. I don't expect this piece of code to work too good (I'm just testing to see if loopback works fine), since there's chance that it will miss some characters (or at least I think so, since a new character may be received before there's a chance for old one to be processed), but I didn't expect it to not work at all.

Interesting thing is that if I enable the Rx interrupt and put the exact same code in the ISR, the data can be received at much greater speed. I need to paste text into terminal window in order to cause the problem.

So any ideas what could be happening?

UPDATE

Looks like I'm getting a mix of framing errors and bit overrun errors. I don't think that I can make the data processing in this case much faster to get rid of the overrun errors, so I'll probably slow down the serial port, but I'm not sure what to do about framing errors.

UPDATE 2

At 9600 b/s, I get much less errors, but still if I copy a wall of text into the terminal, I get errors.

I'm trying to receive data from PIC18F4680's EUSART (using C18 compiler) module and if I type characters in my terminal emulator slow enough, like one or two characters per second, reception works fine. If I try to transmit several characters quickly it seems that reception stops and only device reset solves the problem. Transmission works fine.

The serial port is running at 115200 b/s and and is set-up using following code (clock is 40 MHz):

OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, f_usart); //f_usart=86 for 40 MHz, 115200, or 1040 for 9600 (but it doesn't work at 9600) baudUSART(BAUD_16_BIT_RATE&BAUD_WAKEUP_OFF&BAUD_AUTO_OFF); 

Here's the code I'm using to read from the port:

 if(DataRdyUSART()) { temp=ReadUSART(); WriteUSART(temp); } 

This code is in a main loop which does some other processing too and sends out data over serial port. I don't expect this piece of code to work too good (I'm just testing to see if loopback works fine), since there's chance that it will miss some characters (or at least I think so, since a new character may be received before there's a chance for old one to be processed), but I didn't expect it to not work at all.

Interesting thing is that if I enable the Rx interrupt and put the exact same code in the ISR, the data can be received at much greater speed. I need to paste text into terminal window in order to cause the problem.

So any ideas what could be happening?

UPDATE

Looks like I'm getting a mix of framing errors and bit overrun errors. I don't think that I can make the data processing in this case much faster to get rid of the overrun errors, so I'll probably slow down the serial port, but I'm not sure what to do about framing errors.

UPDATE 2

At 9600 b/s, I get much less errors, but still if I copy a wall of text into the terminal, I get errors.

UPDATE 3

Looks like my laptop's USB to serial adapter is transmitting at 9900 b/s. Could that be the cause of the problem? If yes, is there anything I can do on the PIC side to help solve the problem other than setting the data rate at 9900 b/s?

edited title
Link
AndrejaKo
  • 24k
  • 29
  • 115
  • 192

Problem Bit overrun and framing errors when receiving from EUSART over certian speed with PIC18F4680 EUSART

added 289 characters in body; added 2 characters in body; added 119 characters in body; added 6 characters in body
Source Link
AndrejaKo
  • 24k
  • 29
  • 115
  • 192

I'm trying to receive data from PIC18F4680's EUSART (using C18 compiler) module and if I type characters in my terminal emulator slow enough, like one or two characters per second, reception works fine. If I try to transmit several characters quickly it seems that reception stops and only device reset solves the problem. Transmission works fine.

The serial port is running at 115200 b/s and and is set-up using following code (clock is 40 MHz):

OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, f_usart); //f_usart=86 for 40 MHz, 115200, or 1040 for 9600 (but it doesn't work at 9600) baudUSART(BAUD_16_BIT_RATE&BAUD_WAKEUP_OFF&BAUD_AUTO_OFF); 

Here's the code I'm using to read from the port:

 if(DataRdyUSART()) { temp=ReadUSART(); WriteUSART(temp); } 

This code is in a main loop which does some other processing too and sends out data over serial port. I don't expect this piece of code to work too good (I'm just testing to see if loopback works fine), since there's chance that it will miss some characters (or at least I think so, since a new character may be received before there's a chance for old one to be processed), but I didn't expect it to not work at all.

Interesting thing is that if I enable the Rx interrupt and put the exact same code in the ISR, the data can be received at much greater speed. I need to paste text into terminal window in order to cause the problem.

So any ideas what could be happening?

UPDATE

Looks like I'm getting a mix of framing errors and bit overrun errors. I don't think that I can make the data processing in this case much faster to get rid of the overrun errors, so I'll probably slow down the serial port, but I'm not sure what to do about framing errors.

UPDATE 2

At 9600 b/s, I get much less errors, but still if I copy a wall of text into the terminal, I get errors.

I'm trying to receive data from PIC18F4680's EUSART (using C18 compiler) module and if I type characters in my terminal emulator slow enough, like one or two characters per second, reception works fine. If I try to transmit several characters quickly it seems that reception stops and only device reset solves the problem. Transmission works fine.

The serial port is running at 115200 b/s and and is set-up using following code (clock is 40 MHz):

OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, f_usart); //f_usart=86 for 40 MHz, 115200, or 1040 for 9600 (but it doesn't work at 9600) baudUSART(BAUD_16_BIT_RATE&BAUD_WAKEUP_OFF&BAUD_AUTO_OFF); 

Here's the code I'm using to read from the port:

 if(DataRdyUSART()) { temp=ReadUSART(); WriteUSART(temp); } 

This code is in a main loop which does some other processing too and sends out data over serial port. I don't expect this piece of code to work too good (I'm just testing to see if loopback works fine), since there's chance that it will miss some characters (or at least I think so, since a new character may be received before there's a chance for old one to be processed), but I didn't expect it to not work at all.

Interesting thing is that if I enable the Rx interrupt and put the exact same code in the ISR, the data can be received at much greater speed. I need to paste text into terminal window in order to cause the problem.

So any ideas what could be happening?

I'm trying to receive data from PIC18F4680's EUSART (using C18 compiler) module and if I type characters in my terminal emulator slow enough, like one or two characters per second, reception works fine. If I try to transmit several characters quickly it seems that reception stops and only device reset solves the problem. Transmission works fine.

The serial port is running at 115200 b/s and and is set-up using following code (clock is 40 MHz):

OpenUSART (USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, f_usart); //f_usart=86 for 40 MHz, 115200, or 1040 for 9600 (but it doesn't work at 9600) baudUSART(BAUD_16_BIT_RATE&BAUD_WAKEUP_OFF&BAUD_AUTO_OFF); 

Here's the code I'm using to read from the port:

 if(DataRdyUSART()) { temp=ReadUSART(); WriteUSART(temp); } 

This code is in a main loop which does some other processing too and sends out data over serial port. I don't expect this piece of code to work too good (I'm just testing to see if loopback works fine), since there's chance that it will miss some characters (or at least I think so, since a new character may be received before there's a chance for old one to be processed), but I didn't expect it to not work at all.

Interesting thing is that if I enable the Rx interrupt and put the exact same code in the ISR, the data can be received at much greater speed. I need to paste text into terminal window in order to cause the problem.

So any ideas what could be happening?

UPDATE

Looks like I'm getting a mix of framing errors and bit overrun errors. I don't think that I can make the data processing in this case much faster to get rid of the overrun errors, so I'll probably slow down the serial port, but I'm not sure what to do about framing errors.

UPDATE 2

At 9600 b/s, I get much less errors, but still if I copy a wall of text into the terminal, I get errors.

Source Link
AndrejaKo
  • 24k
  • 29
  • 115
  • 192
Loading