[SPI DMA] Missing first byte

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16073
Level 1
Level 1
Dear Infineon,

I'm currently working on a XMC4700-F100F2048 configured in DAVE with an SPI_MASTER app and a DIGITAL_IO to manage the SPI_CS.

SPI_MASTER app is configured in DMA mode both in transmit and in receive and runs at 1Mb/s, Full-duplex.

My firmware has both a bootloader and an application, developed in two different DAVE projects. SPI works correctly in bootloader, but when the
application starts the first SPI transaction doesn't send the first byte.

To emulate this behavior i developed a test project with the SPI configured as follows:

3323.attach

3324.attach

Here it is the main.c code:


#include //Declarations from DAVE Code Generation (includes SFR declaration)


static uint8_t buffer[3] = { 0x01, 0x02, 0x03 };

void SPI_Send( uint8_t *buffer, uint8_t length )
{
DIGITAL_IO_SetOutputLow( &SPI_SS );
SPI_MASTER_Transmit( &SPI_MASTER, buffer, 3 );
while( SPI_MASTER_IsTxBusy( &SPI_MASTER ) );
while( SPI_MASTER_GetFlagStatus(&SPI_MASTER, (uint32_t)XMC_SPI_CH_STATUS_FLAG_MSLS) != 0U );
DIGITAL_IO_SetOutputHigh( &SPI_SS );
}

int main(void)
{
DAVE_Init();

SPI_Send( buffer, 3 );

SPI_MASTER_Init( &SPI_MASTER );

SPI_Send( buffer, 3 );

while(1U);
}


What it is missing?

Thanks in advance for your kindness,

Andrea
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

You will need to clear the service request in the DLR in between.
int main(void)
{
DAVE_Init();

SPI_Send( buffer, 3 );

XMC_DMA_ClearRequestLine(XMC_DMA1, 3);

SPI_MASTER_Init( &SPI_MASTER );

SPI_Send( buffer, 3 );

while(1U);
}

3331.attach

You find which request line is being used by DMA CH in the DAVE report.
3330.attach

Regards,
Jesus
0 Likes
User16073
Level 1
Level 1
It worked.
Thank you for your response.
0 Likes