MC9S12DP512 Software interrupt within an interrupt service routine

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC9S12DP512 Software interrupt within an interrupt service routine

Jump to solution
1,850 Views
astro_goto
Contributor III
My program is executing a hardware interrupt reading the serial keypad and I want to turn on the display every time the keypad is pressed. This requires sending a command to the display on the same serial channel.  Trying to generate a transmit interrupt after reading the keypad but before the receive rti instruction executes causes the system to hang up. Is there any way to implement a software interrupt so that after the serial receive hardware interrupt finishes the software interrupt will then use the serial transmitter to turn on the display? My programming is in assembly code.
Labels (1)
0 Kudos
1 Solution
361 Views
bigmac
Specialist III

Hello, and welcome to the forum.

 

I assume that you are using a SCI module to communicate with the keyboard/display.  If so, I assume that the interrupt that you refer to is the SCI receive interrupt.

 

It would seem that you are attempting to implement a nested interrupt, with the additional complexity that this requires.  But I don't think that this is necessary for your application.

 

If it is likely that the SCI module will immediately be ready to send (there has been no prior send operation for a while), and the display turn-on command is a single byte, simply send the command byte from within the SCI receive ISR.

 

Alternatively, if the display turn-on command is comprised of multiple bytes, and/or it is likely that the SCI module may not be immediately ready to send, set a flag bit from within the SCI receive ISR, and exit the ISR.  Then poll the flag status from within the main loop, and initiate the command send from there, should the flag be set.  Don't forget to clear the flag bit.

 

Regards,

Mac

 

View solution in original post

0 Kudos
2 Replies
361 Views
astro_goto
Contributor III

Following Bigmac's suggestion, I put the display turn-on commands in the main loop after every instance of keypad read. Works great but more complex as there are multiple software modules that access the keypad. The display is used in the dark and a software timer turns it off after two minutes to conserve power.

 

Thank you for a prompt and clear reply.

0 Kudos
362 Views
bigmac
Specialist III

Hello, and welcome to the forum.

 

I assume that you are using a SCI module to communicate with the keyboard/display.  If so, I assume that the interrupt that you refer to is the SCI receive interrupt.

 

It would seem that you are attempting to implement a nested interrupt, with the additional complexity that this requires.  But I don't think that this is necessary for your application.

 

If it is likely that the SCI module will immediately be ready to send (there has been no prior send operation for a while), and the display turn-on command is a single byte, simply send the command byte from within the SCI receive ISR.

 

Alternatively, if the display turn-on command is comprised of multiple bytes, and/or it is likely that the SCI module may not be immediately ready to send, set a flag bit from within the SCI receive ISR, and exit the ISR.  Then poll the flag status from within the main loop, and initiate the command send from there, should the flag be set.  Don't forget to clear the flag bit.

 

Regards,

Mac

 

0 Kudos