Page 2 of 2

Re: STM32F4Discovery USART3 problem

Posted: Thu Mar 08, 2012 2:15 am
by carnecro
Giovani

my SPI driver is disabled, debugger is on, I do not see any DMA conflict.

I reviewed the code and found error in my Atollic project - I forgot to correct the DMA mask in the hal_lld.h. Now both IDEs, CrossWorks and Atollic generate the same error - _unhandled_exception().

I tracked down the execution of the DMA interrupt with the debugger and found a problem in the call _port_exit_from_isr(). Here is a snipped of my disassembled code

_port_switch_from_isr:
08000470: bl 0x80008f0 <chSchDoReschedule>
08000474: svc 0 <----- _port_exit_from_isr jumps here
08000476: nop
08000478: nop.w
0800047c: nop.w
SVCallVector:
08000480: mrs r3, PSP
08000484: adds r3, #32
08000486: msr PSP, r3
0800048a: movs r3, #0
0800048c: msr BASEPRI, r3
08000490: bx lr <---- return into _idle_thread followed with _unhandled exception

For me a bit mystery, how the linker knows, that the _port_exit_from_isr should continue into SVCallVector? Is this as designed?

Re: STM32F4Discovery USART3 problem

Posted: Thu Mar 08, 2012 8:46 am
by Giovanni
Hi,

I tested the USART3 yesterday by modifying the project in ./testhal/stm32f4xx/UART, it worked as expected, this other issue must be unrelated.

That code is part of the preemption code, ISRs return on that "svc #0" when a context switch is required.

Question: are you using the provided Makefiles or you are using an Atollic project? Could you try using makefiles? this would tell us at least if it is a problem with the project setup or something else.

Note that even if you use an Atollic project, you have to use ChibiOS startup files and ChibiOS linker scripts, is that the case?

Another thing to verify are stack sizes, stacks usage grows if you compile without optimizations (-o0) is that the case?

Giovanni