how to use irq in ChibiOS?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
zhou
Posts: 3
Joined: Thu Jun 16, 2011 2:35 am

how to use irq in ChibiOS?

Post by zhou »

hi,
I write a irq service.Some code like:
CH_IRQ_HANDLER(USART1_IRQHandler) {
CH_IRQ_PROLOGUE();
some code;
CH_IRQ_EPILOGUE();
}
and I use following code to initiate IRQ in main program:
NVICEnableVector(USART1_IRQn,CORTEX_PRIORITY_MASK(1));//this function is defined in /os/ports/GCC/ARMCMx/nvic.h
but,when I have compiled,I cannot find the vector in the vector table of object code,following code is copy from ch.lss list file
80000d0: 08000160 .word 0x08000160
80000d4: 08000160 .word 0x08000160//here should be the entry of USART1_IRQ,but it is just an empty one.
80000d8: 08000160 .word 0x08000160
Anybody know how to use irq?
Thanks,
zhou,
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: how to use irq in ChibiOS?

Post by Giovanni »

You have to include "hal.h" or USART1_IRQHandler is undefined, the macro would create a function "USART1_IRQHandler" that is not mapped in the vectors table.

Be careful with interrupt priorities, if you assign a priority higher than CORTEX_BASEPRI_KERNEL (2) then the kernel will crash. Also note that there priority is different from priority mask, the function expects a priority mask, use:

Code: Select all

NVICEnableVector(USART1_IRQn,
                       CORTEX_PRIORITY_MASK(STM32_SERIAL_USART1_PRIORITY));


Giovanni
zhou
Posts: 3
Joined: Thu Jun 16, 2011 2:35 am

Re: how to use irq in ChibiOS?

Post by zhou »

Thank you,Giovanni.
It's just as what you said.I add "#include 'hal.h'",and it's ok to produce the object code.
Post Reply