koendv / stm32duino-raspberrypi

An arduino toolchain that runs on raspberry pi and targets stm32 arm processors ("blue pill").
8 stars 1 forks source link

cannot use stm32's built in timers #6

Open Joshy-2010 opened 3 years ago

Joshy-2010 commented 3 years ago

Then I try any example sketch what needlessly compiled on my windows machine i get the following error: 'TIMERX_BASE' was not declared in this scope; did you mean 'TIMX_BASE'? (x for timer number) Then I use TIMX_BASE instead as suggest I get the following error: TIMX_BASE is not a pointer

Is there any way to solve this issue other than definig all the pointers myself?

PS: Not meant to sound rude, amazing work getting stm32 support to run on Raspberry Pi at all!

koendv commented 3 years ago

You are not using the Arduino calls, but accessing the timer registers directly? Tough.

The stm32duino timers are handled here:

~/.arduino15/packages/STM32/hardware/stm32/1.9.0/libraries/SrcWrapper/src/stm32/timer.c ~/.arduino15/packages/STM32/hardware/stm32/1.9.0/cores/arduino/HardwareTimer.cpp

Joshy-2010 commented 3 years ago

Yes, i am setting the registers directly. Thank you for your tip, i will look into that

koendv commented 3 years ago

You'll also find CMSIS and STM32F1xx_HAL_Driver directories under .arduino15 hth koen

Joshy-2010 commented 3 years ago

Ok, sorry for the previous post, now I understand the matter better. I was just getting into stm32 programming again and opened some of my over 2 years old programms and wondered why I was getting tons of error messages, especially relating to timers and I2C.

I now realised that I had previously used some (outdated?) stm32-core, as opposed to the new (and in many ways better, for example software serial and the ability to change Hardware serial pins to Alt) stm32duino cores (https://github.com/stm32duino/Arduino_Core_STM32), on which this raspberry core is also based, right??? Unfortunately quite a few definitions have changed since then. That's why it was working on the windows machine (which used the old core) and not the raspberry. (BTW: for anyone wondering why the heck I program stm32's on a raspberry: I have a workshop in the basement and recently installed a raspberry there to debug stuff and quickly change small lines of code)

Anyway I found the definitions for the addresses of the timer registers in the old core and will be collecting and pasting them in a small, custom file which I can include every time I want to control timers directly (like a small library, if that makes sense). I will also look into the new, much nicer library (https://github.com/stm32duino/wiki/wiki/HardwareTimer-library???) which is nowadays used to control the timers, but I just don't have the nerves to rewrite hundreds of lines of old code.

If your interested I can post my little timer definitions file here afterwards.

koendv commented 3 years ago

Glad you found it. Yes, this is a port of the "official" STMicroelectronics stm32 core to raspberry. Among the differences: downloading firmware to stm32 using open source tools instead of using proprietary STM "ST-Link" soft- and hardware.