Page 1 of 1

DMA SPI

Posted: Tue Dec 15, 2020 10:41 pm
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;
}

Re: DMA SPI

Posted: Thu Dec 17, 2020 3:05 pm
by Henry
Hello,

Can you tell us which display you are using please?

Thank you.

Re: DMA SPI

Posted: Wed Dec 23, 2020 3:55 am
by shrivathsa
EVE3-43A

Re: DMA SPI

Posted: Thu Dec 24, 2020 2:49 pm
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

Re: DMA SPI

Posted: Tue Dec 29, 2020 10:44 pm
by shrivathsa
dummy read using, could not do DMA ! what might be the reason?

Re: DMA SPI

Posted: Tue Dec 29, 2020 11:05 pm
by shrivathsa
Its working without DMA, but i want DMA to send large data TFT

Re: DMA SPI

Posted: Sun Jan 03, 2021 11:22 pm
by shrivathsa
i want to use DMA for TX. But the TFT display not responding or waking up.

Re: DMA SPI

Posted: Mon Jan 04, 2021 12:03 pm
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 8349 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

Re: DMA SPI

Posted: Wed Jan 06, 2021 3:56 am
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!

Re: DMA SPI

Posted: Wed Jan 06, 2021 2:11 pm
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.

Re: DMA SPI

Posted: Thu Jan 07, 2021 5:00 am
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...

Re: DMA SPI

Posted: Thu Jan 07, 2021 3:30 pm
by Henry
WOW, that is a serious little board.

Re: DMA SPI

Posted: Fri Jan 08, 2021 11:45 am
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.

Re: DMA SPI

Posted: Fri Jan 08, 2021 1:20 pm
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. :-)