Friday, April 20th 2018, 12:21pm UTC+2

You are not logged in.

  • Login
  • Register

MichaelE

Beginner

Date of registration: Nov 14th 2007

Posts: 1

1

Wednesday, November 14th 2007, 6:27pm

LPC2132/01 FIQ interrupt handler

Hello.

We had to add in our project LPC2132/01 FIQ interrupt handler. Due to bug in most NXP ARM based controllers, I had to disable & re enable both IRQ & FIQ bits in ARM CSPR register while refreshing CPU watchdog. Since embOS functions OS_EnableInt() / OS_DisableInt() in file OS_Priv.h only effects IRQ bit, I made my own functions which set & clear the two bits rather then only one.

My question is – how can I be sure that register r12 is free, and that it is OK to do CPSR register modifications by the help of r12 without saving it 1st to stack (this is how it is done in your code)

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 /********************************************************************
 * HAL_En_IRQ_FIQ()          
 *
 *   This function enable CPU IRQ (used by VIC) and FIQ interrupt
 *
 * Parameters:
 *                                                                   
 * Return:
 *********************************************************************/
 __interwork __arm void HAL_En_IRQ_FIQ(void)
 {
 	__asm("mrs     r12,CPSR")    ;
 	__asm("bic     r12,r12,192");  // Clear CPSR IRQ_DISABLE (bit#7), and FIQ_DISABLE (bit#6) 
 	__asm("msr     CPSR_c,r12")  ;
 }

 /********************************************************************
 * HAL_Dis_IRQ_FIQ()          
 *
 *   This function disable CPU IRQ (used by VIC) and FIQ interrupt
 *
 * Parameters:
 *                                                                   
 * Return:
 *********************************************************************/
 __interwork __arm void HAL_Dis_IRQ_FIQ(void)
 {
 	__asm("mrs     r12,CPSR")    ;
 	__asm("orr     r12,r12,192");  // Set CPSR IRQ_DISABLE (bit#7), and FIQ_DISABLE (bit#6)
 	__asm("msr     CPSR_c,r12")  ;
 }


Michael

Til

Super Moderator

Date of registration: Nov 14th 2007

Posts: 266

2

Thursday, November 15th 2007, 10:44am

Hello Michael,

The register r12 is a scratch register, so you can use it in your function w/o the need to save it on the stack.
If an interrupt occurs the interrupt handler saves and restores register r12, so your own functions are ok.

If you have any further questions regarding this issue please don't hesitate to post it here.

Til