Going beyond the library of firmware, how do you get access to the rest of the STM32F205?

The library of firmware is very good for basic operations, but is by no means comprehensive. In other MCU environments you can get access to an include file that defines memory locations of all of the processors registers and bitfields and the like. However, in the online world of Particle, where do you find this sort of thing? Can someone help me find documentation or how you find a include file?

In this particular case I’d like to get access to the timer registers so I can do some timing measurements on incoming signals.

Hi there @rvnash! You can still access the MCU directly - the firmware doesn’t prevent any privileged operations. You can get access to low level functions by including “stm32f2xx.h”.

HTH! :smile:
mat.

2 Likes

@rvnash, there is one caveat however. The redirection of timer interrupt handlers is not yet supported in the HAL and I know @mdma is working on a simple HAL API to do just that.

1 Like

Thanks. How do I see the contents of stm32f2xx.h, or find documentation for it? I guess I’m confused by the limited access the online IDE gives you to investigate how all of this is working behind the scenes.

Also: this code fails to compile, can’t find stm32fxx.h

#include <stm32f2xx.h>

void setup() {
}

void loop() {
}

Sorry if these are dumb questions, but I’m having trouble getting off the ground.

If you’re using the online IDE, then it’s probably best you let us know specifically what you’re trying to achieve so we can give you pointers. Most bare-metal programming is done locally, where the full sources are available.

Specifically, I have code running on the Teensy using the Freescale timers that reads servo values from 4 pins, and processes them and outputs servo signals on 4 other pins. The idea is to insert a processor in the loop of a remote control system, so that user directions can be smart-ified. It works well, but I’d like to switch over to using the Photon because I want the WiFi to be part of the world, also I like the larger memory and higher clock speed.

Anyway, I’m just learning about the ST timers and the adjustments I’ll need to make. I’ve been exclusively playing with the online IDE. But it sounds like I’ll need to get a GCC cross compiler set up and grab the library from GitHub. Sound right?

@rvnash, the repo is not public yet but will be soon. @mdma, do you have an ETA for that release?

Next week - we have the license!

4 Likes

Woohoo!!!

@rvnash, just to put things in perspective, Broadcom usually only deals with LARGE clients. With Particle, we now have access to commercial-grade Broadcom technology with ZERO licensing cost on an open-source platform for less than twenty bucks. That is INSANE! :stuck_out_tongue:

3 Likes

Sounds like a cool project! We have the Servo library that allows you to read and write servo positions - perhaps that’s an alternative to coding all the low-level stuff yourself?

http://docs.particle.io/photon/firmware/#libraries-servo

1 Like

The Servo library allows you to write positions, and read back what you wrote. But it will not allow you to read external servo signals.

Thanks!

I just checked the code - it’s reading the pulse widths from the servo, so it can read any servo, and not just one that you have previously written to.

So it might be a good idea to consider using this - you could have something working in a matter of minutes rather than spending hours fiddling with timers and the like!

Hi @mdma

What @rvnash wants to do is have several inputs which are driven by servo control signals from another source (like an RC receiver) that he can then manipulate and send back out as servo signals using the servo library. As far as I can see, the servo library always sets the pin to AF_OUTPUT_PUSHPULL; it cannot be an input.

I think the pulseIn function might be useful here but in general you need to have an interrupt on CHANGE for each of these inputs that starts a servo “period” timer on the falling edge, starts a servo “value” timer on the rising edge and then read both period and value timers on the next falling edge before starting over. Since you have to measure around 1ms-2ms with 8-bit accuracy there are many ways that this could be done.

1 Like

That is a correct description of what I want to do, @bko . I considered doing it with interrupts, but I got it working so well self driven with timers on the teensy, I wanted to do that again. With the timers you can any time you want just read out the last latched counter value at the last pulse and you don’t need to worry about interrupts and priority, and now anything the rtos may be doing. Anyway, if I get this working I’ll post and share the code.

Well 2 years later I finally got around to writing this library for the Photon/Electron. It was pretty easy, actually, using interrupts as you suggested, oh so long ago @bko .

The idea behind the library is to be able to connect a typical hobbyist RC receiver to your Photon and be able to read the servo style PWM pulses. It is published as “ServoIn”.

2 Likes