- Notifications
You must be signed in to change notification settings - Fork1k
Closed
Milestone
Description
I found a very weird issue with the SPI code (may affect others as well).
The code bellow works fine, but produces no SPI signal if you comment out the call todelay(0)
in thesetup()
.
I'm testing this on STM32F407VE MCU.
-----Bug repro code start -----
#include<SPI.h>voidsetup() {delay(0);// You comment this line the SPI does generate produce any signals// the delay code can be placed anywhere in this file the location does not matter.// The pins are specific to my setup, they don't matter for the bug SPI.setMOSI(PB5); SPI.setMISO(PB4); SPI.setSCLK(PB3); SPI.begin();}voidloop() { SPI.transfer(0x55);}
-----Bug repro code end -----
The only significant difference I can spot is when I call delay(0), some extra code is linked to the binary. I suspect the SPI code depends on the SysTick handler and does not quite work without it.
I would guess some week linking is causing this weirdness.
Extra code in the working binary:
<HAL_IncTick>:4a03 ldrr2,[pc, #12]; (8000528 <HAL_IncTick+0x10>)6811 ldrr1,[r2, #0]4b03 ldrr3,[pc, #12]; (800052c <HAL_IncTick+0x14>)781b ldrbr3,[r3, #0]440baddr3, r16013strr3,[r2, #0]4770bxlrbf00nop200001c8 .word0x200001c820000004 .word0x20000004<SysTick_Handler>:b508push{r3, lr}f7fe fb56bl8000518 <HAL_IncTick>f7fe fbd1bl8000612 <HAL_SYSTICK_IRQHandler>f7ff fff8bl8001e64 <noOsSystickHandler>bd08pop{r3, pc}