Page 1 of 1

how to use irq in ChibiOS?

Posted: Thu Jun 30, 2011 9:35 am
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,

Re: how to use irq in ChibiOS?

Posted: Thu Jun 30, 2011 12:26 pm
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

Re: how to use irq in ChibiOS?

Posted: Fri Jul 01, 2011 2:07 am
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.