MC9S12DP512 Software interrupt within an interrupt service routine

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MC9S12DP512 Software interrupt within an interrupt service routine

跳至解决方案
2,364 次查看
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.
标签 (1)
0 项奖励
回复
1 解答
875 次查看
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 项奖励
回复
2 回复数
875 次查看
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 项奖励
回复
876 次查看
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 项奖励
回复