Hi!
I have problem with interrupt of DMA on TX LPSPI1.
I want that interrupt of DMA to set after transfer from memory to SPI-TX.
Every 100 ms my programm set a pin CS to LOW and at once begin DMA0_Transmit (transmit 4 bytes). And after I wait IRQ.
For this I set DMA->TCD[0].CSR |= DMA_TCD_CSR_INTMAJOR(1);
But interrupt set at once, before SCK transmit.
void NVIC_init_IRQs(void)
{
S32_NVIC->ICPR[0] |= 1 << (0 % 32); // IRQ0-DMA channel 0 transfer complete: clr any pending IRQ
S32_NVIC->ISER[0] |= 1 << (0 % 32); // IRQ0-DMA channel 0 transfer complete: enable IRQ
S32_NVIC->IP[0] |= (0x0D << 3); // IRQ0-DMA channel 0 transfer complete: priority 13 of 0-15
}
void DMA0_IRQHandler(void)
{
DMA->CINT = DMA_CINT_CINT(0);
PTB->PTOR |= 1 << PTB17;
}
Hi,
it could be normal behavior, I think. DMA is writing to the LPSPI TXFIFO (up to 4 words) so if it is empty DMA write is finished much sooner than actual SPI transmit on the bus.
Try to generate Frame complete interrupt from LPSPI.
BR, Petr
I noticed that the interrupt is always two bytes late. Therefore, I add an additional two bytes every time I send. But me interested how to do it correctly using only DMA without interrupt of the SPI?
Hi,
even if you have TXWATER=0, you have 1deep TXFIFO and shift register, thus after 2nd byte is transmitted, 3dr byte in TXFIFO moves to shift register and DMA can store last byte to TXFIFO, so you get DMA major interrupt.
BR, Petr
Hi, now I am understand!)
Does this mean that this task can only be solved by interrupting the SPI?
I think so.
P.
Hi Petr,
It's good idea, but I set TXFIFO = 0. I will try use interrupt of the LPSPI, thank you.
Hi Timur, could you check whether the optimization level of your project is set to 1 or above? I have met a similar situation when using LPUART while the optimation level of the SDK is set to 1. After changed to 0, never happened again.
Thank you:)
Hi Jeremy, I cheked the optimization level, it were set to 0.