It is not clear to me how the serial interrupt really works. If the interrupt is disabled, the uart can still receive serial data. I would like to know if the interrupt flag is raised even when the interrupt is disabled.
This is a pivotal item since interrupts occurring while a macro call is in place corrupts the stack. This caused me to enable the interrupt at known places to assure that the interrupt service was performed while no macro's were in play.
So - I would like to know
1. Will an interrupt enable service a serial activity that happened previously to the serial enable?
2. Is there a better way to handle the stack - Do I presume right that the stack is corrupted at serial time?
Thanks
Serial interrupt disable versus Uart
Moderator: Benj
- 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: Serial interrupt disable versus Uart
Hello Alan,
9600 baud / 10 bits = 960 bytes per second
1 / 960 bytes = 1.04ms byte period
The circular buffer component in v6 is very useful for doing this type of thing. You can very quickly throw the received data into the circular buffer in the interrupt macro and then when you are ready in your main loop you can poll the buffer to see what data you have received.
Yes the flag will still be set when the interrupt is disabled but this will only happen once. As long as you enable the interrupt at least once every byte period then there is no way for you to miss a byte.I would like to know if the interrupt flag is raised even when the interrupt is disabled.
9600 baud / 10 bits = 960 bytes per second
1 / 960 bytes = 1.04ms byte period
Yes this should be fine for a single byte.1. Will an interrupt enable service a serial activity that happened previously to the serial enable?
It depends what your interrupt service routine is doing. Try and keep as little code here as you can to try to avoid calling the same functions as are called from your main loop.2. Is there a better way to handle the stack - Do I presume right that the stack is corrupted at serial time?
The circular buffer component in v6 is very useful for doing this type of thing. You can very quickly throw the received data into the circular buffer in the interrupt macro and then when you are ready in your main loop you can poll the buffer to see what data you have received.
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