DMA SPI

FTDI/Bridgetek EVE2 & EVE3 & EVE4 SPI TFT Series by Matrix Orbital

Moderator: Mods

Post Reply
shrivathsa
LCD?
Posts: 5
Joined: Thu Dec 10, 2020 10:24 pm

DMA SPI

Post by shrivathsa »

Using EVE81.h library, i am doing code for TFT in stm32. The code works fine without DMA, if I add DMA, the does not wake up..

Code: Select all

void HAL_SPI_WriteBuffer(uint8_t *Buffer, uint32_t Length)
{
	HAL_SPI_Enable();
	//volatile int result = HAL_SPI_Transmit(&hspi1, Buffer, Length, 1000);
	volatile int result = HAL_SPI_Transmit_DMA(&hspi1, Buffer, Length);

	HAL_SPI_Disable();
}

void HAL_SPI_ReadBuffer(uint8_t *Buffer, uint32_t Length)
{
	//EVE requires one dummy read/write before actual data can be read 
	Buffer[0] = 0;
	//volatile int result = HAL_SPI_Transmit(&hspi1, Buffer, 1, 1000);
	//HAL_SPI_Receive(&hspi1, Buffer, Length,1000);
	volatile int result = HAL_SPI_Transmit_DMA(&hspi1, Buffer, 1);
	HAL_SPI_Receive_DMA(&hspi1, Buffer, Length);

}

uint8_t HAL_SPI_Write(uint8_t data)
{
	//volatile int result = HAL_SPI_Transmit(&hspi1, &data, 1, 1000);
	volatile int result = HAL_SPI_Transmit_DMA(&hspi1, &data, 1);
	return 0;
}

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3003
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Re: DMA SPI

Post by Henry »

Hello,

Can you tell us which display you are using please?

Thank you.
Henry J.
President
Matrix Orbital

shrivathsa
LCD?
Posts: 5
Joined: Thu Dec 10, 2020 10:24 pm

Re: DMA SPI

Post by shrivathsa »

EVE3-43A

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3003
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Re: DMA SPI

Post by Henry »

Make sure you are doing the "dummy read", I don't think we have used DMA SPI.

Our STM32 demo code is here

https://github.com/MatrixOrbital/Basic-EVE-Demo-stm32
Henry J.
President
Matrix Orbital

shrivathsa
LCD?
Posts: 5
Joined: Thu Dec 10, 2020 10:24 pm

Re: DMA SPI

Post by shrivathsa »

dummy read using, could not do DMA ! what might be the reason?

shrivathsa
LCD?
Posts: 5
Joined: Thu Dec 10, 2020 10:24 pm

Re: DMA SPI

Post by shrivathsa »

Its working without DMA, but i want DMA to send large data TFT

shrivathsa
LCD?
Posts: 5
Joined: Thu Dec 10, 2020 10:24 pm

Re: DMA SPI

Post by shrivathsa »

i want to use DMA for TX. But the TFT display not responding or waking up.

Rudolph
LCD Guru
Posts: 67
Joined: Wed Feb 28, 2018 11:09 am

Re: DMA SPI

Post by Rudolph »

Hello,

after struggeling with it for a couple of days I just pushed an update for my EVE code library that adds using DMA for the ARDUINO_NUCLEO_F446RE target.
SPI and DMA are using STM32Cube HAL and LL libs.

https://github.com/RudolphRiedel/FT800-FT813

An example that can be compiled with PlatformIO for a handfull of Arduino boards is here:
https://github.com/RudolphRiedel/FT800- ... PlatformIO

The STM32F446RE variant for the Nucleo-64 is using SPI1. Also CS and PDN are using the same pins as the UNO, the ESP32 or the Metro-M4 version.
20210104_195254.jpg
20210104_195254.jpg (80 KiB) Viewed 2644 times
In the picture, "Time1" with 12µs is the time for a display-refresh using DMA.
And "Time2" is for three commands without DMA, checking if EVE is busy, reading the length of the last generated display-list to be display as "DL-size" for debugging purposes and reading the touch-tag register, so these 18µs are static and do not grow with a larger display list.

Next on the list is a demo version for the STM32 without Arduino.

I never used STM32 for anything, do not plan to do so and I only have this one Nucleo Board here right now,
so please forgive me when this is not directly supporting whatever board you are using. :-)

Have fun, Rudolph

Turby
LCD!
Posts: 14
Joined: Tue Dec 01, 2020 4:19 am

Re: DMA SPI

Post by Turby »

Hi Rudolph, (and sorry for the thread hijack!) does your EVE library support SPI DMA for the Teensy 4.1 ? I could look / search but I thought I'd ask he who knows best!

Rudolph
LCD Guru
Posts: 67
Joined: Wed Feb 28, 2018 11:09 am

Re: DMA SPI

Post by Rudolph »

The Teensy boards have not really been on my radar so far, so no, not directly out-of-the-box.
And I am not going to order a Teensy 4.1 now although this is one sick puppy. :-)
The list of things I should be doing is not getting any shorter. :-)

If you like to give it a try, what needs to be modified is EVE_target.h / EVE_target.c.
The code for the other targets should give you some ideas.

Turby
LCD!
Posts: 14
Joined: Tue Dec 01, 2020 4:19 am

Re: DMA SPI

Post by Turby »

Rudolph wrote:
Wed Jan 06, 2021 2:11 pm
The list of things I should be doing is not getting any shorter. :-)
This is the way... ;)
Rudolph wrote:
Wed Jan 06, 2021 2:11 pm
If you like to give it a try, what needs to be modified is EVE_target.h / EVE_target.c.
The code for the other targets should give you some ideas.
I'll give it a go, just waiting for the screen...

Henry
OMNIPRESENT
OMNIPRESENT
Posts: 3003
Joined: Tue Aug 14, 2001 6:00 pm
Contact:

Re: DMA SPI

Post by Henry »

WOW, that is a serious little board.
Henry J.
President
Matrix Orbital

Rudolph
LCD Guru
Posts: 67
Joined: Wed Feb 28, 2018 11:09 am

Re: DMA SPI

Post by Rudolph »

I just checked in PlatformIO what Frameworks are supported for the Teensy 4.1 and found that "only" Arduino is supported.
And on the Website there is this:
"Arduino's IDE software with the Teensyduino add-on is the primary programming environment for Teensy."

So I have to correct myself, it should be working out-of-the-box, at least in a basic configuration.

I just added a section for Teensy 4.1 to the platformio.ini file in the EVE_Test_Arduino_PlatformIO example folder
and just compiled for it, no problem.
I uploaded the updated platformio.ini to Github.

This is however with the generic section for Arduino in EVE_target.c so the pins might be off
and it does not work with DMA.
Plus I can not test it.

It already should be working, only slower than it could be working.

There should be a way to use DMA for SPI transfers on the Teensy 4.1 as the controller itself does support it but enabling DMA
requires specialised code for the target, there is no generic Arduino API for it.

Rudolph
LCD Guru
Posts: 67
Joined: Wed Feb 28, 2018 11:09 am

Re: DMA SPI

Post by Rudolph »

Check out:
https://github.com/RudolphRiedel/FT800- ... PlatformIO

I just pushed an Update for EVE_target.cpp and EVE_target.h in this folder which adds a Teensy 4.1 Arduino Target with DMA support.
As it turned out, the Teensy SPI class already has a function in place for async SPI transfers with callback.

This is of course experimental as I have no way of testing this.
It does compile without warnings which sometimes is a good sign. :-)

Post Reply