I'm quite new to context switch and embedded software development. I'm developing a standalone application (no OS) with aduc7026 and keil uVision3. My problem is that at the end of an uart messagge, which I must receive by interrupt, depending on the content of the messagge I've to return return in main in the state saved before entering in the ISR or I've have to return in a specified point where a funcion call is executed.
Hoping that I've been clear. Does anyone have suggestions?
Thank ìs in advance,
Matteo
"Does anyone have suggestions?"
my first suggestion would be to structure your code so it doesn't do what you are trying to do - it simply sounds "un-natural" and messy.
my 2nd suggestion would be to branch your code based on where your code may jump to. in the main, disable interrupt, execute one of the branches based on a flag, and then turn on the interrupt (to process any messages), and go back to the top. you will in the isr set the flag based on the messages received.
something like this:
1) isr:
receive the message if message is x, set flag to f_x; if message is y, set flag to f_y; ...
2) main code:
disable interrupt; if flag is f_x, execute branch x; if flag is f_y, execute branch y; ... enable interrupt; loop back
the problem with this approach is that it isn't terribly good with real time response.
my 3rd suggestion would be to receive the message in the main, set a flag and then trigger a software interrupt. in the software interrupt, you process the flag (and jump to wherever you want based on the flag).
this approach requires the processing of the flag to be very fast and consumes lots of mcu cycles.