How to write ISR for MC9S08SH32

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to write ISR for MC9S08SH32

441件の閲覧回数
raju_
Contributor I

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

Thanks in advance hcs08 #mc9s08sh32

タグ(2)
0 件の賞賛
返信
1 返信

332件の閲覧回数
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 件の賞賛
返信