Hello,
I'm using SPI2 of STM32F407 series to send data to a DAC module each 50us.
After some seconds, system is halted due to an Transfer Error Interrupt Flag (TEIF), which was detected in function spi_lld_serve_rx_interrupt(). This function was called by Vector78, which is the IRQ Handler for DMA Stream (1,3) (#define in mcuconf: #define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3)).
So I don't get, why a SPI RX interrupt is called (and why actually activated?), I just want to send data. Furthermore, i don't get why a transfer error is generated. A transmission of one SPI data block takes about 5us, so enough time with a cycle of 50us.
By the way: Why does it take so long, until ChipSelect is set/reset (It is set via hal_lib_spi_select(&hal_lib_spi_2_hdl)).
Regards,
Daniel
STM32F4 SPI: DMA Transfer Error Interrupt
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: STM32F4 SPI: DMA Transfer Error Interrupt
Hi,
Are debug options enabled in chconf.h? those could give an hint about the problem.
I don't know why CS takes so long, is the code compiled with optimizations? are clocks initialized correctly?
Note that you should never call spi_lld_ functions directly, use the official interfaces.
Giovanni
Are debug options enabled in chconf.h? those could give an hint about the problem.
I don't know why CS takes so long, is the code compiled with optimizations? are clocks initialized correctly?
Note that you should never call spi_lld_ functions directly, use the official interfaces.
Giovanni
Re: STM32F4 SPI: DMA Transfer Error Interrupt
Hi Giovanni,
thanks for your fast response.
I don't use the Chibi-OS as Kernel. I'm working OS-less. I enabled OSAL_DBG_ENABLE_ASSERTS and OSAL_DBG_ENABLE_CHECKS in osalconf.h, but I didn't get on with it until now.
I don't use code optimizations. SYSCLK is set to 168Mhz, APB1 is clocked with 42Mhz. With the used prescaler of 4, I get a SPI frequency of ~10Mhz.
Yes, sorry for that. I meant function call to spiSelect().
I don't understand why function call to spi_lld_serve_rx_interrupt() is executed. I don't want to receive data, I just want to send data via SPI. Do you have an explanation for it? Might a transfer error occur due to timing problems (when I send 4 channels to DAC module instead of 1 each 50us, the transfer interrupt happens more likely)?
thanks for your fast response.
Are debug options enabled in chconf.h? those could give an hint about the problem.
I don't use the Chibi-OS as Kernel. I'm working OS-less. I enabled OSAL_DBG_ENABLE_ASSERTS and OSAL_DBG_ENABLE_CHECKS in osalconf.h, but I didn't get on with it until now.
I don't know why CS takes so long, is the code compiled with optimizations? are clocks initialized correctly?
I don't use code optimizations. SYSCLK is set to 168Mhz, APB1 is clocked with 42Mhz. With the used prescaler of 4, I get a SPI frequency of ~10Mhz.
Note that you should never call spi_lld_ functions directly, use the official interfaces
Yes, sorry for that. I meant function call to spiSelect().
I don't understand why function call to spi_lld_serve_rx_interrupt() is executed. I don't want to receive data, I just want to send data via SPI. Do you have an explanation for it? Might a transfer error occur due to timing problems (when I send 4 channels to DAC module instead of 1 each 50us, the transfer interrupt happens more likely)?
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: STM32F4 SPI: DMA Transfer Error Interrupt
The driver enables the DMA interrupt regardless if the callback is enabled or not.
DMA errors could be caused by DMA accessing unmapped memory or by starting an operation while the driver is still sending old data.
Giovanni
DMA errors could be caused by DMA accessing unmapped memory or by starting an operation while the driver is still sending old data.
Giovanni
-
- Posts: 137
- Joined: Fri May 08, 2015 1:09 pm
- Location: Dresden, Germany
- Has thanked: 10 times
- Been thanked: 5 times
Re: STM32F4 SPI: DMA Transfer Error Interrupt
Hi,
@daniel_s: i can reproduce your image of your first post. What you see is not the time to set the chip select. It is the runtime of the function spiStartSend.
@daniel_s: i can reproduce your image of your first post. What you see is not the time to set the chip select. It is the runtime of the function spiStartSend.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: STM32F4 SPI: DMA Transfer Error Interrupt
Hi,
There is already a polled function in the SPI driver, it is best used when transferring small data and low latency is required.
spiPolledExchange()
Giovanni
There is already a polled function in the SPI driver, it is best used when transferring small data and low latency is required.
spiPolledExchange()
Giovanni
Who is online
Users browsing this forum: No registered users and 31 guests