I am writing a library for a SPI screen and this involves busing larger amounts of data via SPI to the screen.
I have noticed if I have a large amount of data and I send it in 1 large chunck it goes very fast but if I send the same amount of data in lots of little then it is very very slow.
e.g if I have a file (150kb big) on flash that has the image and needs to be sent to the screen RAM via SPI. If I have a program that loops reading 1 byte then sending that byte then repeating it will take maybe 20secs to move all the data but if I have then same program but change it from reading 1 byte then sending to reading 1kb then sending then it takes under a sec. The larger the chunks the faster it is to move the same data from flash to screen via SPI.
I put a scope on the clock line of the SPI bus to see what's happening and ran this code
Code: Select all
data = b'x00'
while True : hspi.write(data)
For me to become better educated and write better programs I like to understand why it is so.