2020-08-31 08:13 AM
I'm trying to set up SPI transfer via DMA which is triggered by LPTIM1 on STM32H745IIK6. Unfortunately for some reason, no SPI activity is present regardless of the config register values, which seem to be correct. Here's the LPTIM1 and DMA1 config:
And I'm starting the timer with:
HAL_LPTIM_Init(&hlptim1);
HAL_LPTIM_Counter_Start(&hlptim1, 190);
HAL_LPTIM_PWM_Start(&hlptim1, 190, 95);
And trying to initialize DMA with:
HAL_SPI_TransmitReceive_DMA(&hspi1, (uint8_t*)&spi_tx_buffer, (uint8_t*)&spi_rx_buffer, 1);
LPTIM1 output works, I can see it on the PD13, but as I said, no activity on any of the SPI pins.
Can you give me some pointers regarding the initialization of automatic SPI DMA transfer which is triggered by LPTIM1? I have tried to follow a few examples from this forum which use direct writing to registers but none of them work?
Solved! Go to Solution.
2020-09-01 09:13 AM
> after enable executes for TX (stream 3) LISR bit TEIF3 sets to 1.
A transfer error, see below.
> After a while LISR resets to 0 and TEIE bit in S3CR resets to 0
You have an error interrupt in place, don't you. That Cube placed it, is no excuse, it's your program.
> S2M0AR=0x20000048 and S3M0AR is 0x2001ffe4
- both these addresses are in DTCM.
In 'H7, DMA1 does not have connectivity to DTCM, see Bus-master-to-bus-slave interconnect table in RM. That's why the transfer error. The Rx DMA hasn't been triggered so far, so it did not attempt a transfer thus hasn't encountered the error.
I don't use 'H7 so I may be wrong, check yourself.
I didn't check the rest; I am not very familiar with the trigger/sync features of DMAMUX.
JW
2020-08-31 01:38 PM
Read out and check/post the relevant LPTIM, DMAMUX, DMA, SPI and GPIO registers content.
JW
2020-09-01 03:28 AM
Here are the relevant registers:
These are all the states immediately after the execution of HAL_SPI_TransmitReceive_DMA. Weird thing is that S2CR EN bit is set to 1, while S3CR EN bit is 0 even tho __HAL_DMA_ENABLE(hdma) executes in both cases but after enable executes for TX (stream 3) LISR bit TEIF3 sets to 1. After a while LISR resets to 0 and TEIE bit in S3CR resets to 0, picture below:
In DMAMUX1 C2CR SOIE bit is 1, while C3CR SOIE bit is reset to 0 after a while.
In SPI, SPE and CSTART is high all the time.
HAL_SPI_TransmitReceive (without DMA) works no problem, so I'm fairly certain that GPIO is set up correctly.
DT
2020-09-01 09:13 AM
> after enable executes for TX (stream 3) LISR bit TEIF3 sets to 1.
A transfer error, see below.
> After a while LISR resets to 0 and TEIE bit in S3CR resets to 0
You have an error interrupt in place, don't you. That Cube placed it, is no excuse, it's your program.
> S2M0AR=0x20000048 and S3M0AR is 0x2001ffe4
- both these addresses are in DTCM.
In 'H7, DMA1 does not have connectivity to DTCM, see Bus-master-to-bus-slave interconnect table in RM. That's why the transfer error. The Rx DMA hasn't been triggered so far, so it did not attempt a transfer thus hasn't encountered the error.
I don't use 'H7 so I may be wrong, check yourself.
I didn't check the rest; I am not very familiar with the trigger/sync features of DMAMUX.
JW
2020-09-02 03:06 AM
Thank you very much, that was the main problem,
I have reallocated the buffer arrays with
uint8_t spi_tx_buff[8] __attribute__((section(".TxBUF")));
uint8_t spi_rx_buff[8] __attribute__((section(".RxBUF")));
where sections are defined in the linker script as
Mem1 (xrw) : ORIGIN = 0x2400E200, LENGTH = 0x1dc4
Mem2 (xrw) : ORIGIN = 0x2400FFC4, LENGTH = 0x1dc4
.RxBUF (NOLOAD) : { *(.RxBUF) } >Mem1
.TxBUF (NOLOAD) : { *(.TxBUF) } >Mem2
and everything works now, including synchronization with the LPTIM1.
DT
2020-12-30 05:53 AM
can you share a github of how you configured the synchronization with the LPTIM1
your help is appreciated