Interrupt not work in application

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

Interrupt not work in application

Jump to solution
1,529 Views
ZhaiHui
Contributor II

I have an application, without OS, which works well alone. So I think I have set necessary interrupt enable. But after being integrated with bootloader provided by third party, normal functions work well but interrupt became not work. I have relocated VTOR in cstart.s as following:

/****************************************************************************/
/* Settings */
/****************************************************************************/
#define ROM_START (0x00076000) /* ROM start address (align = 32) */
#define ROM_END (0x0007EFFF) /* ROM end address (align = 32) */
#define STACK_SIZE (0x1000) /* Stack size in byte */

/****************************************************************************/
/* System stack */
/****************************************************************************/
PUBLIC __stack_top

SECTION .stack:DATA:REORDER:ROOT(8)
DATA

__stack_btm:
DS8 STACK_SIZE
__stack_top:

/****************************************************************************/
/* C startup */
/****************************************************************************/
PUBLIC __iar_program_start,__program_start

EXTWEAK __iar_init_core
EXTWEAK __iar_init_vfp
EXTWEAK __iar_data_init3

SECTION .text:CODE:REORDER(2)
THUMB

/*----------------------------------*/
/* Entry */
/*----------------------------------*/
__iar_program_start:
__program_start:

cpsid i

ldr r0 , =__stack_top
mov r13, r0

ldr r0 , =ROM_START
ldr r1 , =0xE000ED08 /* VTOR */
str r0, [r1, #0]

FUNCALL __program_start, __iar_init_core
bl __iar_init_core

....

The linker.icf is as following:

define memory mem with size = 4G;
define region IROM_region = mem:[from 0x00076410 to 0x0007efff]; // Code Flash
define region EROM_region = mem:[from 0x10000000 to 0x1000ffff]; // Data Flash
define region ERAM_region = mem:[from 0x14000000 to 0x14000fff]; // Flex RAM
define region IRAM_region = mem:[from 0x1fff8000 to 0x1fffffff] // SRAM_L
                                              | mem:[from 0x20000000 to 0x20006fff]; // SRAM_U

initialize by copy { rw };
do not initialize { section .noinit, section .stack };

place at address mem:0x00076000 { ro section .intvec, ro section .trmval };
place at address mem:0x00076400 { ro section .flscfg };

place in IROM_region { ro };
place in EROM_region { ro section .dflash };
place in IRAM_region { first block CSTACK { section .stack }, rw };
place in ERAM_region { rw section .flxram };

I doubt  the new vector is not recognized or there is setting in bootloader that effect interrupt enable, is anyone can give me some hints?

0 Kudos
1 Solution
1,498 Views
ZhaiHui
Contributor II

Hello Diana,

We found the BASEPRI is set to 16 by bootloader and priority of LPUART interrupts are set as 15. After we change the priority of LPUART to 0, the interrupt worked. We think even priority of LPUART is 15, it should also work as it is higher than 16 of BASEPRI, isn't right?

View solution in original post

0 Kudos
4 Replies
1,513 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello,

 

At first, could you, please, check if the VTOR is set correctly after the jump into the application? Just to be sure if it is relocated.

Which MCU do you use?

 

Thank you.

Best regards,

Diana

0 Kudos
1,486 Views
ZhaiHui
Contributor II

Hello Diana,
We are using FS32K144HAT0VLLR. And we confirmed that VTOR changed to 0x00076000 as we set at the start of our application in cstart.s.
By the way, as we can not debug the software after integrating with bootloader provided by third party, we modified the application a little and confirmed the VTOR value by reading it and sent it out by CAN message.
When read NVICISER and NVICISPR we found that LPUART interrupts which we want to use are enabled but in pending state. But besides LPUART interrupts, there interrupts which we not use enabled or pended. We tried to disable them and clearing the pending ones by following code at start of application, but it does not work, the unexpected interrupts are still enabled or pended.
FSL_NVIC->ICER[0] = 0xFFFFFFFF;
FSL_NVIC->ICER[1] = 0xFFFFFFFF;
FSL_NVIC->ICER[2] = 0xFFFFFFFF;
FSL_NVIC->ICER[3] = 0xFFFFFFFF;
FSL_NVIC->ICPR[0] = 0xFFFFFFFF;
FSL_NVIC->ICPR[1] = 0xFFFFFFFF;
FSL_NVIC->ICPR[2] = 0xFFFFFFFF;
FSL_NVIC->ICPR[3] = 0xFFFFFFFF;

0 Kudos
1,474 Views
dianabatrlova
NXP TechSupport
NXP TechSupport

Hello,

 

Thank you for your information.

>>"But besides LPUART interrupts, there interrupts which we not use enabled or pended."

Have you disabled and clear pending interrupts in the bootloader before the jump into the application?

In this case, the SW reset before the jump can be useful, after that there should not be any pending interrupt. 

Could you, please, check also the ICSR register?

About BASEPRI, it should work as you described according to the CortexM4 manual (the higher the value, the lower priorities):

"When BASEPRI is set to a nonzero value, it prevents the activation of all exceptions with the same or lower priority level as the BASEPRI value."

Note: When I'm using S32DS I cannot debug the code after the jump into the application, but I have access to the registers. Meaby your IDE has the same feature.

 

Best regards,

Diana

0 Kudos
1,499 Views
ZhaiHui
Contributor II

Hello Diana,

We found the BASEPRI is set to 16 by bootloader and priority of LPUART interrupts are set as 15. After we change the priority of LPUART to 0, the interrupt worked. We think even priority of LPUART is 15, it should also work as it is higher than 16 of BASEPRI, isn't right?
0 Kudos