Bare-Metal STM32: Exploring Memory-Mapped I/O And Linker Scripts

In the first installment of this series we had a brief look at the steps needed to get a bare-metal application running on an STM32 microcontroller. While this allowed us to quickly get to the juicy stuff, there are two essential elements which make an MCU so easy to use. One is found on the hardware side, in the form of so-called memory-mapped I/O (input/output), the other is the information contained in the files that are passed to the linker when we build a firmware image.

Memory-mapping of hardware peripheral registers is a straightforward way to make them accessible to the processor core, as each register is accessible as a memory address. This is both convenient when writing the firmware code, as well as for testing, as we can use a memory mapping specific for unit or integration testing.

We will take an in-depth look at this way of testing, as well as how these linker script files are connected to the memory layout. Continue reading “Bare-Metal STM32: Exploring Memory-Mapped I/O And Linker Scripts”

IRC Over LoRa, For When Things Really Go South

As a society, we’ve become accustomed to always-on high-speed data connections, whether we’re at home on the computer or out and about with a mobile device. But what happens if a natural disaster knocks out the local infrastructure? Sure some people will be able to fire up their radio if they need to reach out and touch someone, but even among hackers, hams are a minority. What we really need is a backup Internet.

The team behind the CellSol project hopes to show that building a volunteer-operated distributed communications network is not only within the capabilities of the hacker community but probably much easier and cheaper to do than you might think. Each node in the network, known as a Pylon in CellSol parlance, can shuttle data between the LoRa backbone and WiFi-enabled devices like smartphones and computers. Once the network is up and running, users don’t need any special hardware or software to use it.

Now to be clear, nobody is talking about surfing the web here. When a user connects to one of the ESP32 Pylons, they’ll be able to access a simplistic chat system through their browser. If the Pylon has an active Internet connection the chat can be bridged to an IRC channel. Without Internet connectivity, the pylon will simply give users on the CellSol network a means to communicate among each other. To keep things simple there’s no user names, private messages, or encryption. This is bare-bones, end-of-the-world style communication.

Want to join the CellSol revolution? All you really need is an ESP32, a LoRa radio, and the open-source firmware. If you get something like the Heltec LoRa 32 development board, you don’t even need to solder anything together. Just flash the board and go. Once you have a few Pylons going, you can also put together a cheap repeater node using a LoRa equipped Arduino. Both devices are small and energy efficient enough that they could easily be battery or solar powered. As you can see in the video after the break, the team even envisions a future where they could be dropped off in public areas via drone.

This isn’t the first time we’ve seen the ESP32 used to establish an off-grid LoRa communications network, and like those previous attempts, it’s usefulness will largely depend on how many people you can convince to set up their own nodes and repeaters. But if you’ve got some open minded friends who live relatively close by, this could be a great way to have a little chat.

Continue reading “IRC Over LoRa, For When Things Really Go South”

A Beeping Toy Helps A Blind Dog Play Fetch

When a beloved pet goes blind, it doesn’t mean they can’t or don’t want to play fetch anymore, only that the game must change a bit. [Bud Bennett]’s dog Lucy has slowly lost her sight to progressive renal atrophy but is still up for playing with toys, so [Bud] decided to make a beeper that can go inside various stuffed toys to help Lucy locate them. Lucy doesn’t care for commercial toys that chime constantly, especially once she’s got it in her mouth.

This tiny package is centered around an LIS3DH accelerometer and programmed with a PIC16F18313. When the toy is thrown up in the air, the accelerometer determines that it’s in free fall and triggers an interrupt on the PIC. The piezo buzzer starts beeping so Lucy can find it, then stops a short while later and waits for the next free fall. The power dissipation is so low that [Bud] expects to charge the 120 mAh LiPo battery about once a year.

We bet that communication between [Bud] and Lucy is already pretty good, but maybe she could be more expressive with a doggy soundboard.

Bare-Metal STM32: Blinky And The Secret Of Delay Functions

One of the very first examples for an MCU or SoC usually involves the famous ‘Blinky‘ example, where an LED is pulsed on and off with a fixed delay. This is actually a lot more complicated than the ‘Pushy‘ example which we looked at in the first installment of this series. The reason for this is that there’s actually quite a story behind a simple call to delay() or its equivalent.

The reason for this is that there are many ways to implement a delay function on a microcontroller (MCU), each of which comes with their own advantages and disadvantages. On an STM32 MCU, we get to choose between essentially an active delay (while loop), one implemented using the SysTick timer and using one of the peripheral timers. In the latter two cases we also have to use interrupts.

In this article we’ll take a look at all three approaches, along with their advantages and disadvantages.

Continue reading “Bare-Metal STM32: Blinky And The Secret Of Delay Functions”

ESP32 Spectrum Analyzer Taps Into Both Cores

We probably don’t need to tell the average Hackaday reader that the ESP32 is a powerful and extremely flexible microcontroller. We’ve seen some incredible projects using this affordable chip over the last few years, and by the looks of it, the best is yet to come. That’s because it always takes some time before the community can really figure out how to get the most out of a piece of hardware.

Take for example the Bluetooth audio player that [squix] was recently working on. Getting the music going was no problem with the esp32-a2dp library, but when he wanted to add some visualizations the audio quality took a serious hit. Realizing that his Fast Fourier transform (FFT) code was eating up too much processor power, it seemed like a great time for him to explore using the ESP32’s second core.

[squix] had avoided poking around with the dual-core nature of the ESP32 in the past, believing that the second core was busy handling the WiFi communication. But by using the FreeRTOS queue system, he wrote some code that collects audio data with one core and runs the actual FFT magic on the other. By balancing the workload like this, he’s able to drive the array of 64 WS2812B LEDs on the front of the Icon64 seen in the video after the break.

Even if you’re not terribly interested in running your own microcontroller disco, this project may be just the example you’ve been waiting for to help get your mind wrapped around multitasking on the ESP32. If you want to master a device with this many tricks up its sleeve, you’ll need all the help you can get.

Continue reading “ESP32 Spectrum Analyzer Taps Into Both Cores”

The Macro Keyboard Is On Deck

The idea of a reconfigurable macro keyboard is a concept that has been iterated on by many all the way from custom DIY keypads to the polarizing TouchBar on MacBooks. The continual rise of cheap powerful microcontrollers with Wi-Fi and 3D printers makes rolling your own macro keyboard easier every year. [Dustin Watts] has joined the proverbial club and built a beautiful macro pad called FreeTouchDeck.

We’ve seen macro keyboards that use rotary encoders to cycle through different mappings for the keys. FreeTouchDeck has taken the display approach and incorporates a touch screen to offer different buttons. [Dustin] was inspired by a similar project called FreeDeck, which offers six buttons each with a small screen. FreeTouchDeck is powered by an ESP32 and drives an ILI9488 touch screen with an XPT2046 touch controller. This means that FreeTouchDeck can offer six buttons with submenus and all sorts of bells and whistles. A connection to the computer is done by emulating a Bluetooth keyboard. By adding a configuration mode that starts a web server, FreeTouchDeck allows easy customization on the fly.

[Dustin] whipped up a quick PCB that makes it easy to solder the ESP32 and the TFT together, but a breadboard works just fine. Gerbers for that are available on GitHub. To wrap it all up, a nice 3D printed shell encloses the whole system in a clean, tidy way. The code, documentation, and case designs are all on his GitHub.

Continue reading “The Macro Keyboard Is On Deck”

Wireless Quad Voltmeter Brings It All Together

If you’re reading Hackaday, you almost certainly have a voltmeter. Matter of fact, we wouldn’t be surprised to hear you had two of them. But what if you needed to monitor four voltage levels at once? Even if you had four meters, getting them all connected and in a convenient enough place where you can see them all at once is no small feat. In that case, it sounds like the multi-channel wireless voltmeter put together by [Alun Morris] is for you.

Built as an exercise in minimalism, this project uses an array of components that most of us already have kicking around the parts bin. For each transmitter you’ll need an ATtiny microcontroller, a nRF24L01+ radio, a small rechargeable battery, and a handful of passive components. On the receiver side, there’s an OLED screen, another nRF radio module, and an Arduino Nano. You could put everything together on scraps of perfboard like [Alun] has, but if you need something a bit more robust for long-term use, this would be a great excuse to create some custom PCBs.

While the hardware itself is pretty simple, [Alun] clearly put a lot of work into the software side. The receiver’s 128 x 32 display is able to show the voltages from four transmitters at once, complete with individual indicators for battery and signal level. When you drill down to a single transmitter, the screen will also display the minimum and maximum values. With the added resolution of the full screen display, you even get a very slick faux LCD font to ogle.

Of course, there are some pretty hard limitations on such a simple system. Each transmitter can only handle positive DC voltages between 0 and 20, and depending on the quality of the components you use and environmental considerations like temperature, the accuracy may drift over time and require recalibration. Still, if you need a way to monitor multiple voltages and potentially even bring that data onto the Internet of Things, this is definitely a project to take a look at.

Continue reading “Wireless Quad Voltmeter Brings It All Together”