Author Topic: Slow SPI transfer on STM32G031K8 nucleo  (Read 192 times)

0 Members and 1 Guest are viewing this topic.

Offline jeet55

  • Contributor
  • Posts: 17
Slow SPI transfer on STM32G031K8 nucleo
« on: April 16, 2021, 03:30:48 pm »
so I am interfacing an RGB OLED display (NHD-1.69-160128UGC3). I have set the SPI clock to 32Mhz and I am using HAL drivers. for some reason updating the whole display takes like a second. I am unable to understand why. please someone help me. I have attached my library files below.
 

Offline tru

  • Regular Contributor
  • *
  • Posts: 83
  • Country: gb
Re: Slow SPI transfer on STM32G031K8 nucleo
« Reply #1 on: April 16, 2021, 04:00:42 pm »
From the datasheet:
https://www.newhavendisplay.com/specs/NHD-1.69-160128UGC3.pdf

If you look at the 4-wire SPI timing table (page 12), it shows tCYCS = 100ns (minimum), and if my conversion is correct that means the maximum SPI clock rate is 10MHz.
You're overclocking it!  Try setting the SPI to 10MHz or slower.
 

Offline jeet55

  • Contributor
  • Posts: 17
Re: Slow SPI transfer on STM32G031K8 nucleo
« Reply #2 on: April 16, 2021, 04:10:47 pm »
I know i am over clocking it. If i select frequency 10mhz and less it just becomes more slow.
 

Offline errorprone

  • Contributor
  • Posts: 19
Re: Slow SPI transfer on STM32G031K8 nucleo
« Reply #3 on: April 16, 2021, 04:39:50 pm »
Can try turning up the optimizations to see if it’s good enough.  HAL functions are slow compared to direct register access. A oscilloscope would help determine which functions are causing the most delays.
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 6463
  • Country: fr
Re: Slow SPI transfer on STM32G031K8 nucleo
« Reply #4 on: April 16, 2021, 04:55:01 pm »
A quick look at your code shows that you're sending pixel data one pixel at a time in dedicated functions, each with a separate SPI frame. That's a LOT of overhead. If you want faster access, you'll need to do things differently, the faster way being to implement some framebuffer and sending whole blocks of pixels in one go through SPI.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf