Input Capture interrupts not firing (STM32F030R8)

08 Jan 2017

Hi folks,

I am trying to implement a 1Wire slave on an STM32F030R8, using input capture to determine the pulse length.

Unfortunately, I can't seem to get the timer interrupts to fire, do you have any advice?

Notes:

  • I am compiling this offline using GCC 6.2 from https://launchpad.net/gcc-arm-embedded
  • I have generated the init code in STM32CubeMX and merged it in
  • I am using the HAL directly for GPIO interrupts to reduce latency (not relevant to the problem)
  • The input 1Wire signal is wired to pins PB2 & PA6
  • The poll loop shows the counter stuck at 0
  • The timer is set to to interrupt mode in the readMode() method

The serial output is as follows:
../OneWireSlave.cpp:210 OneWireSlave(): Binding interrupt
../OneWireSlave.cpp:53 MX_GPIO_Init(): Setting up GPIO
../OneWireSlave.cpp:77 MX_TIM3_Init(): Setting up Timer3
29 ef be ad de 00 00 1a 10010100 11110111 01111101 10110101 01111011 00000000 00000000 01011000
../OneWireSlave.cpp:192 readMode(): Read mode
../OneWireSlave.cpp:239 OneWireSlave(): OneWireSlave completed
../DS2408.cpp:21 DS2408(): Clearing listener
../main.cpp:24 main(): Online, SystemCoreClock = 48000000 Hz
../main.cpp:25 main(): Address = 00000222 2914971392

/media/uploads/deece/main.cpp
/media/uploads/deece/onewireslave.cpp
/media/uploads/deece/onewireslave.h
/media/uploads/deece/ds2408.h
/media/uploads/deece/ds2408.cpp
/media/uploads/deece/trace.h

09 Jan 2017

I decided to dump the registers for further analysis.

/media/uploads/deece/timerregisters.txt

09 Jan 2017

After setting the period to 65535, the counter is now counting, but I am still not getting the the interrupt to fire.

09 Jan 2017

Ok, I think I can see a problem, looking at the generated map during linking, I can see that I am getting the weakly linked null implementation of TIM3_IRQHandler, rather than my strongly linked implementation from main.cpp.

I think LTO may be playing shenanigans, I'll have to investigate how to tame it.

 .text.Default_Handler
                0x08004aa0        0x2 A:/eclipse/mbed-os/BUILD/mbed/TARGET_NUCLEO_F030R8/TOOLCHAIN_GCC_ARM/startup_stm32f030x8.o
...
                0x08004aa0                TIM16_IRQHandler
                0x08004aa0                TIM3_IRQHandler
                0x08004aa0                EXTI4_15_IRQHandler
09 Jan 2017

My current link line is attached.

/media/uploads/deece/linker.txt

09 Jan 2017

Ok, I figured out what the problem was - the interrupt symbol name was getting C++ mangled - I wrapped it in an 'extern "C"' and it's now called as expected.