I have connected Sharp Memory Display 400 x240 to Teensy 4.0 and it works great. Very fast and responsive expesially when run at 10 Mhz SPI, it seems to run even with 14 Mhz but the specified is only 2 MHz.
Anyway, it works great, but the display update blocks quite a lot the other tasks, like filtering analogue inputs.
I have been trying to find some simple exambles how to use DMA on SPI with Teensy 4.0, found couple of posts but nothing really useful.
How is the DMA SPI working on Teensy 4.0? any good examples. or would there be other methods to make the SPI transfer more efficient, not faster but less resources consuming.
This is the current display update function
void setup() {
SPI.beginTransaction(SPISettings(10000000, LSBFIRST, SPI_MODE0));
I am hoping I could manage the SPI.transfer(lineData, 51); using DMA.
Anyway, it works great, but the display update blocks quite a lot the other tasks, like filtering analogue inputs.
I have been trying to find some simple exambles how to use DMA on SPI with Teensy 4.0, found couple of posts but nothing really useful.
How is the DMA SPI working on Teensy 4.0? any good examples. or would there be other methods to make the SPI transfer more efficient, not faster but less resources consuming.
This is the current display update function
void setup() {
SPI.beginTransaction(SPISettings(10000000, LSBFIRST, SPI_MODE0));
Code:
void drawScreen() {
uint8_t lineData[52];
uint8_t updatedLines[240];
uint8_t updates;
//update only lines that have updates.
updates = 0;
for (int y = 0; y < 240; y++) { updatedLines[y] = 0; }
for (int y = 0; y < 240; y++) { for (int x = 0; x < 50; x++) {
if( screenData[x][y] != screenDataOld[x][y]) {
updatedLines[y] = 1; updates = 1;
screenDataOld[x][y] = screenData[x][y];
}
}}
if( updates == 1 ){
digitalWrite(CS,HIGH); //start screen update
SPI.transfer(0x01 | Vcom);//Command
for (int y = 0; y < 240; y++) {if( updatedLines[y] == 1 ){
SPI.transfer(y); //line number, must be send separate to work correct
for (int x = 0; x < 50; x++) { lineData[x] = flipByte(screenData[x][y]); }//data for one line
lineData[50] = 0x00;//Trailer for line
SPI.transfer(lineData, 51);
}}
SPI.transfer(0x00); //Trailer for screen
digitalWrite(CS,LOW);
}
}
I am hoping I could manage the SPI.transfer(lineData, 51); using DMA.