Hi all,
I'm using UART0 RX interrupt on the ATMEGA 328 to call a created service routine named ISR_UART for handling incomming data, and this worked quite fine.... for most cases till now
For example, when I receive a command (byte) form the UART (PC-Terminal), ISR_UART executes the according routine.
Usually this routines are quite small, like sending some numbers back to the PC, and this always worked fine.
But now I'm sending data form an external SPI-Flash connected to the ATEMGA back to the PC (Baud Rate 38400), which takes from some second up to minutes.
The complete data is transferred to the PC always quite correct (as I can see in the Terminal program), but every now and then it seem that at the end of the ISR_UART, which is obviously reached, it doesn't jump back into the main routine.
It seems, it stucks in this interrupt routine as other commands from the PC are still executed well on the ATMEGA, except the main program!
It always needs a software reset (also one of my working UART commands) to get back to main.
I'd really appreciate any ideas how to solve this problem.
Isn't there a "jump" or a "goto"- command, like used within macro routines to jump back to main?
Many thanks!!
Niro
Problem with UART0 RX interrupt
Moderator: Benj
-
- Posts: 77
- Joined: Mon Jan 03, 2011 8:58 pm
- Has thanked: 29 times
- Been thanked: 10 times
- Contact:
Re: Problem with UART0 RX interrupt
...no ideas at all?
Thanks!
Niro
Thanks!
Niro
- Attachments
-
- ISR.jpg (19.88 KiB) Viewed 4786 times
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Problem with UART0 RX interrupt
I think you have already realized that the problem is the longer interrupt routine.
You should keep these as short as possible.
To do that, could you simply set a global flag in your interrupt routine to indicate what response is required,
then in your main look for the flag and take action on it.
You should keep these as short as possible.
To do that, could you simply set a global flag in your interrupt routine to indicate what response is required,
then in your main look for the flag and take action on it.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Problem with UART0 RX interrupt
The circular buffer component is a good way of storing the incoming data from the interrupt to be processed later on outside of the interrupt macro.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 77
- Joined: Mon Jan 03, 2011 8:58 pm
- Has thanked: 29 times
- Been thanked: 10 times
- Contact:
Re: Problem with UART0 RX interrupt
...many thanks guys!
I think, I'll be using the flag, because it can be implemented quite easily into my code.
Thanks,
Niro
I think, I'll be using the flag, because it can be implemented quite easily into my code.
Thanks,
Niro