infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 3 of 3

Thread: [SPI DMA] Missing first byte

  1. #1
    New Member New Member acanidio is on a distinguished road
    Join Date
    Nov 2018
    Location
    Milan
    Posts
    2
    Points
    35

    [SPI DMA] Missing first byte

    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:

    Click image for larger version

Name:	SPI_general.png
Views:	0
Size:	8.1 KB
ID:	3684

    Click image for larger version

Name:	SPI_Advanced.png
Views:	1
Size:	21.7 KB
ID:	3685

    Here it is the main.c code:

    Code:
    #include <DAVE.h>                 //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
    Last edited by acanidio; Nov 15th, 2018 at 07:34 AM. Reason: Edited the code to wait without the interrupt.

  2. #2

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    441
    Hi,

    You will need to clear the service request in the DLR in between.
    Code:
    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);
    }
    Click image for larger version

Name:	dave_dma_spi_bootloader.png
Views:	1
Size:	45.7 KB
ID:	3692

    You find which request line is being used by DMA CH in the DAVE report.
    Click image for larger version

Name:	dave_dma_dlr_report.png
Views:	1
Size:	26.1 KB
ID:	3691

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    New Member New Member acanidio is on a distinguished road
    Join Date
    Nov 2018
    Location
    Milan
    Posts
    2
    Points
    35
    It worked.
    Thank you for your response.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.