Programming advice when using interrupts
Posted: Mon Dec 03, 2018 8:36 am
Hi,
I have a program i am writing with code present in the main loop. I am also using the CAL UART component. I have an interrupt routine that is triggered by data being received by the UART. The interrupt routine processes the incoming data. Once this is done a status needs to be transmitted from the UART immediately. The host requires a response in under a 1mS to prevent faults being generated.
What i wanted to know is what is the best way of doing this. I am not sure if i am right but you cannot call the send maco for the CAL UART from inside the interrupt routine without errors being generated. Waiting until you return to the main loop and sending from there would lead to problems in regards to too much of a time delay as you cannot guarantee what part of the main loop the interrupt was triggered. One way i thought would be to use a "C" code icon and manually send the data to the UART from there from within the interrupt routine. Does anyone have any other ideas of doing this efficiently.
Thanks in advance
I have a program i am writing with code present in the main loop. I am also using the CAL UART component. I have an interrupt routine that is triggered by data being received by the UART. The interrupt routine processes the incoming data. Once this is done a status needs to be transmitted from the UART immediately. The host requires a response in under a 1mS to prevent faults being generated.
What i wanted to know is what is the best way of doing this. I am not sure if i am right but you cannot call the send maco for the CAL UART from inside the interrupt routine without errors being generated. Waiting until you return to the main loop and sending from there would lead to problems in regards to too much of a time delay as you cannot guarantee what part of the main loop the interrupt was triggered. One way i thought would be to use a "C" code icon and manually send the data to the UART from there from within the interrupt routine. Does anyone have any other ideas of doing this efficiently.
Thanks in advance