cancel
Showing results for 
Search instead for 
Did you mean: 

Using SPI / HAL - Where to start?

JGiem.1
Associate III

Hey, mechatronics student here. So ive been trying to make the transition from Arduino to STM32 lately, and am a little overwhelmed by hardware-oriented programming.

So I can get things like Blink running, and know my way around C good enough to have done some smaller things already, but I want to start using little more complex peripherals now.

I thought about using a 240x240 TFT display, driven with the ST7789 chip, and I wanted to do very basic things for the beginnning - like painting dots (single pixels) for the beginning. But thats where it already starts to get a little too complex for me. With the Arduino, you have libraries and those libraries (like TinyTFT for the Arduino) handle the communication to the peripheral (TinyTFT is utilizing SPI aswell), so you just need to tell it what to do - paint a pixel, row 2 column 6 or whatever.

So my first guess is that I would need to write such functions similar as in said libraries myself - no problem, effortwise. Now ive read through the documentation of the ST7789 and - in short - I need to tell the chip all sorts of things (configuration etc.) - all the way down to what to display finally. That needs, as said, to be done via SPI and by (my understanding) sending certain number combinations to certain registers in the ST7789. Ive looked up the HAL documentation for SPI_Transmit (which, according to some SPI tutorials, seems like the appropriate choice for the job), and am a little lost in how to utilize it. How much of the encoding (means the translation from "human instruction" to chip-understandable binary) does it do for me, how much do I need to do myself? Can I tell HAL which register to write to and what to write, or does it need some steps before that (lets assume that the chip select has already happened, thats comparably simple to understand)?

I feel like I know too little to be able to actually ask precise enough. I'm having a hard time finding good explainations (especially for the Nucleo Board, I am using the F446RET6) - could you tell me where I can find "beginner tutorials" (or good explainations) for more complex things like actually talking to the ST7789 from scratch? Understanding what I'm doing is most important to me. What do I need to research? What's up with things like "0x03" or something like that? how can I adress registers correctly?

Any help is greatly appreciated, I will try and answer every question you might have.

The project I am thinking of is trying to put my Lepton 3.5 thermal imaging sensor to use, reading out it's video stream, putting that into an array (=one image frame) and displaying that array on a TFT-display. But I want to get the display to work first, obviously. Baby steps.

1 ACCEPTED SOLUTION

Accepted Solutions
MasterT
Lead

You can continue to work in arduino IDE, just install add-on from ST:

https://github.com/stm32duino/Arduino_Core_STM32#boards-available

TFT library I'm using mcuFriend + Adafruit GFX, running like a charm on my nucleo-F446re

View solution in original post

2 REPLIES 2
MasterT
Lead

You can continue to work in arduino IDE, just install add-on from ST:

https://github.com/stm32duino/Arduino_Core_STM32#boards-available

TFT library I'm using mcuFriend + Adafruit GFX, running like a charm on my nucleo-F446re

AScha.3
Chief II

right, i tried same.

the "end" of arduino is , when you need some parts , like ADC , running at special rate and DMA to fill data arrays; i had the same problem and tried at first, adding some lib to arduino , but to much work; so i tried to use the mcuFriend lib and get it in the STM32cubeIDE and this was much more easy and working perfect.

so i can recommend: try arduino, for a first test, and if TFT working fine or other ready made libs you find there, then copy/modify them and use together with HAL etc. in STM32cubeIDE .

tis gives you 100% control over the chip.

If you feel a post has answered your question, please click "Accept as Solution".