infineon4engi@twitter twitter

infineon4engineers Facebook

infineon@linkedin linkedin

infineon@youtube youtube

+ Reply to Thread
Results 1 to 1 of 1
  1. #1
    New Member New Member Schnegg is on a distinguished road
    Join Date
    Feb 2017

    SPI to Memory transfer (PGDMA)


    I'm trying to read the input from an SPI interface trough GPDMA to the memory of an XMC4800.

    In detail:
    With a high PWM interrupt frequency (PWM > 750kHz) I'm sampling the SPI interface.
    On every interrupt when the frame length of the SPI input is reached (18bit), I want to shift the SPI FIFO to the memory over the GPDMA.

    In the attachment file there are some details about the protocol:
    Channel 0: PWM Interrupt pin --> ADC starts convertsation at high edge
    Channel 1: MOSI
    Channel 2: CLK (about 72MHz)
    Channel 3; MISO --> Data from ADC 18bit
    Click image for larger version

Name:	screenshot.png
Views:	7
Size:	195.0 KB
ID:	3033

    How do I achieve this?
    Some GPDMA example for Dave 4 (peripheral to peripheral , memory to peripheral and vice versa) would help alot.

    Code at the moment without PGDMA:
    #include <DAVE.h>                 //Declarations from DAVE Code Generation (includes SFR declaration)
    #include <stdio.h>
    uint16_t j = 0;
    uint16_t data[2048];
    uinbt32_t dataArray[1024];
    bool test = false;
    void compare_match_handler(void)
    	//empty = (uint16_t)>OUTR;
    	//empty = (uint32_t)>OUTR;
    	//>IN[0] = 0xFFFF; // 32 Bit
    	//>IN[0] = 0xFFFF;>IN[0] = 0x3FF; // 10 Bit --> to get all 18 bits correct>IN[0] = 0x3FF;
    	//>IN[0] = 0x1FF; // 9 Bit
    	//>IN[0] = 0x1FF;
    	while(XMC_USIC_CH_RXFIFO_GetLevel( < 2);
    	data[j++] = (uint16_t)>OUTR;
    	data[j++] = (uint16_t)>OUTR;
    int main(void)
    	DAVE_STATUS_t status;
    	status = DAVE_Init();           /* Initialization of DAVE APPs  */
    	if(status != DAVE_STATUS_SUCCESS)
    		/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
    		XMC_DEBUG("DAVE APPs initialization failed\n");
    	/* Placeholder for user application code. The while loop below can be replaced with user application code. */
    		if(j > 1024 && test == fale)
    			// Get 18 bit ADC values 
    			for(uint32_t i = 0; i < sizeof(data); i += 2)
    				//dataArray[i] = (uint32_t)((data[i] << 17) | (data[i + 1] << 7));
    				data[i] &= ~(1 << 9);
    				dataArray[i] = (uint32_t)((data[i] << 10) | (data[i + 1] << 1));
    			test = true;
    Last edited by Schnegg; Jul 10th, 2017 at 06:56 AM.

Tags for this Thread


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.