I am developing a example where I use the UART driver to read data of a compass. When the program is executed, it obtained a _unhandled_exception. From this post http://www.chibios.com/forum/viewtopic.php?f=3&t=1305&start=20#p28854, I copy the file exceptionvectors.c in my project.
My rxend callback is;
Code: Select all
static void rxend_cb_(UARTDriver *uartp) {
(void)uartp;
chSysLockFromISR();
memcpy(raw_msg, rx_block_buffer, READING_BLOCK_SIZE_L4R5ZI);
read_block_uart_driver_(raw_msg);
uartStartReceiveI(&UART_DRIVE_L4R5ZI, READING_BLOCK_SIZE_L4R5ZI,
rx_block_buffer);
chSysUnlockFromISR();
BLINKER_TOGGLE
;
}
The read_block_uart_driver_() function reads (read from buffer, no from driver) until a complete message is available and, in this case, signals another thread to process the message. Internally, the buffer passed by parameter is copied to another buffer and this buffer is processed. The code used to signal the thread is:
Code: Select all
push_buffer_policyI(&uart_bp, bp); //adds the new element to FIFO object
chEvtSignalI(uart_th_consumer, UART_CONSUMER_EVENT_L4R5ZI);
After executing the program, the stack contains the following:
Code: Select all
Thread [1] (Suspended: Signal 'SIGINT' received. Description: Interrupt.)
4 HardFault_Handler() undefined_exception_handler.c:48 0x08001bfa
3 <signal handler called>() 0xfffffff1
2 _idle_thread() chsys.c:72 0x08000e40
1 _port_thread_start() chcoreasm_v7m.S:119 0x080002c2
Line marked (FAULT_PSP has the value: 0x20000b00 <ch_idle_thread_wa+120>):
Code: Select all
void HardFault_Handler(void) {
#ifdef DEBUG_BACKTRACE
asm("mrs %0, psp" : "=r"(FAULT_PSP) : :);
stack_pointer = FAULT_PSP; // <-- HERE, it has the value: 0x20000b00 <ch_idle_thread_wa+120>
// Here will be good to assert Error LED, like
// GPIOA->ODR |= 1;
while(1);
#else
Disassenbly:
Code: Select all
08001bfa: b.n 0x8001bfa <HardFault_Handler+10>
I don't know how to interpret this output. Can anyone help me?
Thank you.