• AVR Freaks

AnsweredHot!UART issue in PIC32MZ

Author
iamnaveen685
Starting Member
  • Total Posts : 58
  • Reward points : 0
  • Joined: 2018/09/18 07:44:02
  • Location: 0
  • Status: offline
2019/05/21 06:39:09 (permalink)
0

UART issue in PIC32MZ

Hi,
 
I am trying to create a UART RX_HANDLER which should work for Receiving the data. I am facing the issue with the RX handler where whenever send data more than 10 bytes the controller stops Working i.e hanging and if I clear the OERR overrun register when it is set it is working without hanging but data is Missing,
 
kindly help me on this issue
#1
dvvrcognizant
Starting Member
  • Total Posts : 34
  • Reward points : 0
  • Joined: 2019/03/13 07:48:11
  • Location: 0
  • Status: offline
Re: UART issue in PIC32MZ 2019/05/21 07:38:00 (permalink)
4 (1)
This is a classical problem. You need to empty the UART FIFO as soon as possible. This shall be done in the ISR. In the ISR you need to put the data byte received in a circular buffer. And, in the mail program, you need read the data byte(s) from the circular buffer. If the receiver is slower than sender then Overrun Error cannot be avoided.
#2
iamnaveen685
Starting Member
  • Total Posts : 58
  • Reward points : 0
  • Joined: 2018/09/18 07:44:02
  • Location: 0
  • Status: offline
Re: UART issue in PIC32MZ 2019/05/21 07:42:16 (permalink)
0
Hi,
Thanks for the reply .I am confused on clearing the UART FIFO ,help me on this how can I read the UART FIFO.
#3
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: UART issue in PIC32MZ 2019/05/21 13:30:43 (permalink) ☼ Best Answerby iamnaveen685 2019/06/05 05:06:36
5 (1)
I don't think dvvrcognizant actually looked at your code, which IS reading the data into a circular buffer,
but the you commit the cardinal sin of doing a long slow operation (printf) from INSIDE the ISR.
That will guarantee you will lose data.
Pull it out of there right now.
Also, you have a flag named READ_DONE to tell your non-interrupt code there is data present, but you never set it.
I guess it didn't work for you because you didn't add a "volatile" qualifier to the variable.
You must always do that if a variable is changed inside an ISR and referred to from outside the ISR.
Change the definition to:
volatile uint8_t READ_DONE=0;



 

Nearly there...
#4
iamnaveen685
Starting Member
  • Total Posts : 58
  • Reward points : 0
  • Joined: 2018/09/18 07:44:02
  • Location: 0
  • Status: offline
Re: UART issue in PIC32MZ 2019/06/05 05:05:03 (permalink)
4 (1)
Hi 
Thanks for the Reply,
 
the Issue is As you said i was using the printf in the UART HANDLER,
 
after removing the Printf from the handler it is Working Fine..
#5
Jump to:
© 2019 APG vNext Commercial Version 4.5