How to write ISR for MC9S08SH32

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

How to write ISR for MC9S08SH32

526 次查看
raju_
Contributor I

Hi can anyone help me with how to write ISR for MC9S08SH32 controller.

Thanks in advance hcs08 #mc9s08sh32

标记 (2)
0 项奖励
回复
1 回复

417 次查看
tonyp
Senior Contributor II

You don't specify if you want in C or assembly.

Writing an ISR in C uses your compiler's specific syntax which varies somewhat between vendors (e.g., some use the `interrupt` keyword).

In assembly language, it's more straight forward.  You need to write your code as you would a normal subroutine but be sure to do four things:

1. Change the RTS instruction to RTI

2. Explicitly protect the H register (i.e., use PSHH on entry and use PULH, RTI to exit)

3. Make sure you acknowledge the source of the interrupt to avoid re-entering the ISR for the same event.

4. Point the related interrupt vector to the start of your ISR routine.  (e.g., ORG $FFxx followed by DW My_ISR)

If you use an MMU capable variant (usually those have 64KB or more of Flash), make sure the ISR is located in non-paged memory (i.e., outside the MMU paging window).

The rest is the same as writing normal subroutines.  However, ISRs should be as short as possible in terms of execution time.  With a few exceptions that require truly instant attention, the plan is this: Acknowledge the event, save whatever needs to be saved in some data structure (e.g., a queue), and then let the main loop handle the event at a normal pace.

Hope this helps.

0 项奖励
回复