Midimetric
New member
Hello,
I have toyed with the Teensy 3.1, a color TFT and an SD card reader.
When loading a bitmap from the card and displaying it on the TFT, it seems I lost a lot of time just to manage the transfer of bytes...
Here is a pseudo code of what I actually do:
read 480 bytes from a sector (remaining 32 bytes of the sector are ignored because the bitmap is already saved in a TFT compatible format, i.E. one line per sector):
- allocate a buffer uint16_t buffer[240]
- spi select SD
- spi out -> read command, sector #
- spi in <- 0x00, 0x00
- loop 240 times (using 4 words fifo as in spi4teensy library)
... - spi out -> 0x0000
... - spi in <- 16 bits data goes to *buffer++
- spi unselect SD
write a line on the tft ( 240 x 16 bits pixels )
- select CMD line
- select TFT spi
- spi out -> set columns 0 to 239, set lines y to y, write command
- spi in <- 0x00,0x00... (ignored)
- unselect TFT spi
- unselect CMD line
- select TFT spi
- loop 240 times (using 4 words fifo as in spi4teensy library)
... - spi out -> pixel data from *buffer++
... - spi in <- 0x0000 ignored
- spi unselect TFT
This is working fine, even at full spi speed (24MHz ?) but i feel like there a lot of "zeros" transfered and ignored both ways...
My question is, does it seems feasible to temporarily connect the SDO from the SD card to the SDI of the TFT ?
This would be done with some CD40xxx switch.
The pseudo-code would then become :
- select CMD line
- select TFT spi
- spi out -> set columns 0 to 239, set line y to y, write command
- spi in <- 0x00,0x00... (ignored)
- unselect TFT spi
- unselect CMD line
- spi select SD
- spi out -> read command, sector #
- spi in <- 0x00, 0x00
- spi select TFT
- activate the switch connecting SD SDO to TFT SDI and disconnect Teensy MOSI from TFT SDI
- loop 240 times
... - spi out -> 0x0000
... => SD SDO pushes value directly to TFT SDI
... - spi in <- 16 bits data ignored
- spi unselect SD
- spi unselect TFT
In effect, I just skip writting to a buffer then pushing the buffer to the TFT !
FPS is doubled !
Does it make sense ?
I have toyed with the Teensy 3.1, a color TFT and an SD card reader.
When loading a bitmap from the card and displaying it on the TFT, it seems I lost a lot of time just to manage the transfer of bytes...
Here is a pseudo code of what I actually do:
read 480 bytes from a sector (remaining 32 bytes of the sector are ignored because the bitmap is already saved in a TFT compatible format, i.E. one line per sector):
- allocate a buffer uint16_t buffer[240]
- spi select SD
- spi out -> read command, sector #
- spi in <- 0x00, 0x00
- loop 240 times (using 4 words fifo as in spi4teensy library)
... - spi out -> 0x0000
... - spi in <- 16 bits data goes to *buffer++
- spi unselect SD
write a line on the tft ( 240 x 16 bits pixels )
- select CMD line
- select TFT spi
- spi out -> set columns 0 to 239, set lines y to y, write command
- spi in <- 0x00,0x00... (ignored)
- unselect TFT spi
- unselect CMD line
- select TFT spi
- loop 240 times (using 4 words fifo as in spi4teensy library)
... - spi out -> pixel data from *buffer++
... - spi in <- 0x0000 ignored
- spi unselect TFT
This is working fine, even at full spi speed (24MHz ?) but i feel like there a lot of "zeros" transfered and ignored both ways...
My question is, does it seems feasible to temporarily connect the SDO from the SD card to the SDI of the TFT ?
This would be done with some CD40xxx switch.
The pseudo-code would then become :
- select CMD line
- select TFT spi
- spi out -> set columns 0 to 239, set line y to y, write command
- spi in <- 0x00,0x00... (ignored)
- unselect TFT spi
- unselect CMD line
- spi select SD
- spi out -> read command, sector #
- spi in <- 0x00, 0x00
- spi select TFT
- activate the switch connecting SD SDO to TFT SDI and disconnect Teensy MOSI from TFT SDI
- loop 240 times
... - spi out -> 0x0000
... => SD SDO pushes value directly to TFT SDI
... - spi in <- 16 bits data ignored
- spi unselect SD
- spi unselect TFT
In effect, I just skip writting to a buffer then pushing the buffer to the TFT !
FPS is doubled !
Does it make sense ?
Last edited: