My project is emulating a game cartridge ROM. From my testing I discovered a standard Arduino was too slow to “bit bang” the hardware I was working with.
What I’m seeing so far with the STM32F103 board is that using digitalWrite() the speed is equivalent to an Arduino (test a logic analyzer). So I was wondering: Is there a way I can get direct access to the ports like I can with AVR C? Or am I going to have to use an ST-Link and STM32Cube?
Thanks in advance!
Yes you can easily access the hardware directly
digitalWrite calls
gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, val);
See
https://github.com/rogerclarkmelbourne/ … ple/gpio.h
which boils down to
val = !val; /* "set" bits are lower than "reset" bits */
dev->regs->BSRR = (1U << pin) << (16 * val);
One thing to bear in mind is that the low level functions ( apart from the lowest level where you directly access the memory mapped registers), are non standard.
This topic has been covered many times before… but our code base was written before STM released and Open Source version of the official CMSIS Standard Peripheral library.
So the gpio_xxxxx functions look nothing like the CMSIS ones.
In the very long term we may move to using the CMSIS, but I susoect in that case, we would need to retain the gpio_xxx functions for legacy compatibility
This technology is very fast and allows quite nice code that is easy to read. By addressing every bit individually many complexities in register structures can be avoided.
Here is an example of this technology as used in STM32F429
http://www.emblocks.org/wiki/tutorials/ … it_banding
Cheers, Ollie
I think I need a little more control over the hardware so set myself up an environment in KEIL μVision following this link https://www.youtube.com/watch?v=_QXoTNP9GIw (Apologies, I originally thought STM32CubeMX was the environment).
Currently I’m uploading to the board with an FTDI and Flash loader demonstration, following steps here http://stm32f4-discovery.com/2014/09/pr … with-uart/
I know this is STM32duino, so hope people don’t mind me asking a few of questions here:
– Is there a way to upload within μVision via UART? Ideally without having to swap jumpers, like in Arduino.
– Is there a good language reference for the platform?
– Is there a good place I can learn about the GPIO setup and usage? These are very different from ARM, as Roger says, so a little lost.
– Assuming you’d rather keep this forum STM32duino, is there another place you’d recommend where I could get help on coding and hardware for the platform?
Again, thank you so much for such insightful and helpful posts!
for heathens, non-believers and doubting thomas’s
do google ‘gnuarm site:stm32duino.com’ – ooddles of the stuff
have a look at the gnuarmeclipse and tutorial for it
if you want to use OSS to compile istr it suggests exporting from CubeMX as Truevision(??), that source can be then pulled into eclipse. Keil has size limits on the free one.
there are a lot of stm32/eclipse/windows tutorials, most annoying when looking for the linux ones.
stephen
If you are going down a non Arduino route, then STMs own forum is probably the best place to get answers.
I don’t think anyone on this forum uses Keil. AFIK we all use GCC, but we don’t all use the Arduino IDE. e.g some people use Eclipse, some use Visual Micro
However the common denominator is the use of the “Arduino” form of API / HAL ( derived from Wiring)

