KF5N Radio Experimentation Site

Return to the home page.


T41-3 Part 2 Technologies

As explained before in Part 1, the original T41 architecture includes a display module which places a high computational burden on the Teensy 4.1 single-core CPU. There are three display items that change with respect to time during normal operation of the receiver:

  1. The RF spectrum.
  2. The audio spectrum.
  3. The S-meter.

There is a fourth, the Morse decode indicator, but that one is trivial compared to the above.

The way these features work is via data transmission (and reception) via the “SPI” bus. The Teensy has the SPI “master”, and the RA8875 display driver is the “slave”. Data in the form of numbers is constantly passed from Teensy to display via the SPI bus, 512 numbers to draw the RF spectrum and 255 numbers to draw the audio spectrum. The S-meter is much simpler, being only a single number per update, but a lively signal strength indicator is an important feature of any decent HF receiver.

Meanwhile, none of this display update activity can interfere with the receiver audio. The receiver audio is on what is called a “hard” schedule. If audio data doesn’t arrive on time, there will be an annoying gap in the audio. No one wants that! As hams we listen to our radios for hours on end. Audio anomalies will drive you crazy!

The way the problem is handled is to intersperse the drawing of the display with the processing of the audio. It has to be done this way, because the display is not fast enough. When the CPU is driving the SPI bus, it can’t process data (DSP operations). If it spends too much time servicing the display via the SPI, the audio will drop, and the op will not be happy. So a little piece of the spectrum is drawn, audio is processed, another piece of the spectrum is drawn, and then the next block of audio is processed, etcetera. This is a very precisely executed dance, and it makes for some crazy and fragile software. I’ve spent many hours trying to optimize that code, with much frustration.

To make matters worse, the SPI bus traffic is doubled because you also have to erase the old spectrums before plotting the new!

The Technology We Already Own: Direct Memory Access (DMA)

A modern microcontroller has a “Central Processing Unit” surrounded by a data bus, memory, and numerous peripherals. The combination of features is highly customizable and is designed for a particular type of application. “Peripherals” means devices in silicon designed for narrow tasks, like data converters, timers, clocks, memory controllers, I2C, I2S, SPI, Ethernet, USB, etcetera. A high-speed bus connects all of this, and managing the flow of data between CPU and peripherals is a big problem.

In the case of large contiguous blocks of data there is a powerful solution which takes the burden of managing data transmission off of the CPU:

https://en.wikipedia.org/wiki/Direct_memory_access

The Teensy 4.1 includes a total of 32 “eDMA” (enhanced DMA) channels, and if you have built a T41, you are already using eDMA. This is the primary technology used by the Teensy Audio Library and the Open Audio Arduino Library to move “blocks” of data from the I2S interfaces (input), and to the DSP signal chains to be processed by the CPU (lots of math), and then back out via the I2S output to speaker/headphone or transmitter IQ channels.

Display + DMA???

The original T41 architecture does not use DMA to transfer display data. If it was possible, a significant amount of CPU power would become available for other tasks. These other tasks would be performed in-between the hard-scheduled DSP audio processing. Currently, a lot of that in-between time is spent by the CPU manipulating display data.

Last summer I spent several weeks working on a quad output F32 I2S output class for the Open Audio Arduino Library. I learned a lot about eDMA! For one thing, this is not an easy device to work with! This also included dealing with I2S, a technology I’ve never touched before. So it was more than DMA. Anyhow, what I learned is that the easiest thing to transfer with DMA is a continuous chunk of data. A basic C style array of numbers is a good example. There can’t be any “chip selects” woven into the data. Just a serial stream of numbers please!

DMA was something I had been thinking about to solve the T41 display problem.

So what I did next is take a good long look at the RA8875 display driver. That is the driver used in our display modules from “BuyDisplay”. Displays can come with or without the driver chip. For the T41, a display “module” complete with driver chip is what we want.

To make a long story short, I did a lot of study of the RA8875 data sheet. And then I did a bunch of studying of the SPI waveforms during operation of the T41. I have a 4-channel oscilloscope which can probe the four SPI signals (chip select, clock, MOSI, MISO) and it has the ability to decode the data. So I could interpret the commands and data being sent to the display by looking at the oscilloscope decode.

Do you know why the T41 goes dead when the display is disconnected? That is because for a lot of the “drawing” operations, the display is continually interrogated (polling) to determine if the display is done drawing. For example, when you can command the RA8875 to draw a line. You don’t send individual pixels. You send two x-y coordinates (and color), and it computes the locations of the pixels in-between. BUT you have to wait for it to complete the calculations and light up the pixels before sending another command. The display sends the information back to the Teensy via the MISO connection. Yes, the SPI communication goes both ways! So if the display is disconnected, there is no way for the Teensy to interrogate the display, and things come to a silent halt. I also observed that it takes longer to draw a long line. So if you have a spectrum with a bunch of strong signals, it is going to take longer to draw that spectrum. So the spectrum drawing time is band dependent!

What I was focusing on at the time was the most obvious time-consuming operation, and that is the drawing of the RF spectrum. The RF spectrum is the result of a 512 width FFT, so you need to draw that many line segments. The RA8875 library included with the TeensyDuino has a “draw line” function which is used to draw the spectrum, one segment at a time (also erase one old segment at a time).

What I was hoping was that “draw line” was a library basic function, and that the RA8875 could also support drawing multiple connected line segments using serial data (an array) which could be easily transmitted via DMA. I looked real hard, but I failed to find that capability in the RA8875. Perhaps I missed something, and I am underselling the capability of the RA8875. Maybe someone else knows better, and I would really like to know more.

That was the end of the RA8875 investigation and I proceeded to search for a different display technology.

Embedded Video Engine 4

Next was the usual internet searching and reading of bunches of data sheets. There are quite a few display controllers out there. It kind of makes sense, as these days there are smaller displays everywhere and there is a demand for easy-to-use controllers.

So I somehow stumbled upon this, the second critical T41-3 technology:

https://brtchip.com/product/bt817q/

The “programming guide” is here:

https://brtchip.com/wp-content/uploads/2024/08/BRT_AN_033_BT81X-Series-Programming-Guide.pdf

Since I was almost entire focused on efficient drawing of the RF spectrum, the following feature captured my attention:

“Line strip drawing primitive”

This is indeed what I was looking for, and it can be serialized in such a way as to be easily transmited by DMA!

Other Interesting Features of the BT817 Controller

The SPI bus clock rate maximum is 30MHz. That is triple the specified rate of the RA8875! In the T41, we are over-clocking the SPI bus by a factor of two. This seems to work, but it is fragile. Many have reported difficulty with the display, and that was found to be due to SPI bus errors.

What is interesting about the BT817 is that SPI bus speed appears to be less important. That is because of DMA. I have been running the SPI bus at 12MHz. Much less than the current T41 with RA8875, and yet the BT817 at 12MHz massively outperforms the RA8875.

But wait, there is more! The BT817 is capable of “dual” and “quad” SPI. That means two, or four data lines, and a corresponding increase in data rate. That means the combined higher specified bus clock rate plus serial-parallel bus of dual or quad SPI will result in really spectacular data rates relative to the RA8875. Is the Teensy dual or quad SPI capable? YES. It has “FlexIO”. I’ve already found a description of how that is done in the PJRC forum. However, it remains to be seen if dual or quad SPI is really necessary. This will require more experience with the BT817 controller. So for now, the single SPI will be suitable for moving forward with T41-3 development.

Widgets

Another interesting feature of the BT817 controller are the built-in “widgets”. These things are baked-in to the silicon. That means that a very powerful touch-screen can be designed with (claimed) minimal effort. A touch-screen T41-3 variant? YES, that may be possible.

There are numerous other features which could be exploited to create interesting radio interfaces. The BT817 is an amazing device! And then there is the EVE5 BT82X series. Even more powerful! But we should stick to the BT817 for now, it is overwhelming enough as it is.

Part 2 Conclusion

My investigation indicated a search was in order for an alternative display technology for the T41-3 project. The display controller needs to have a simple method of drawing a multiple line-segment for the RF and audio spectrums. Also, it must format the drawing command and data in such a way that facilitates transmission via DMA to SPI bus.

The Bridgetek BT817 controller appears to meet these requirements. A prototype T41-3 has demonstrated the desired features, and so far, it is exceeding expectations. Other interesting features of the BT817 have not been explored.

There could be other controllers out there that meet the requirements. Maybe there is something better? For now, I am moving forward with BT817 EVE.

DMA is included with the Teensy 4.1 and it is an integral part of the T41-3 “Enhanced Performance Experimenter Platform” technology.

Part 3 will cover commercially available display modules using the BT817 controller, including the module used in the prototype.

– 73 Greg KF5N