infineon4engi@twitter infineon@linkedin infineon4engineers infineon@youtube
twitter Facebook Linkedin Youtube

+ Reply to Thread
Results 1 to 1 of 1

Thread: XMC4200 VADC Code Optimization

  1. #1
    Beginner Beginner oliver.blasius is on a distinguished road
    Join Date
    May 2014

    XMC4200 VADC Code Optimization

    I encountered a problem with our project, when enabling Code Optimization (O1). Our ADC_initialize() Function causes the device to go to the default Handler.
    The function only consists of XMC Library functions.

    This is what the function looks like:

    void ADC_initialize(void)
    	/* Global Init */
    	XMC_VADC_GLOBAL_Init(VADC, &ADC_Global_handle);
    	XMC_VADC_GLOBAL_BackgroundInit(VADC, &ADC_Background_handle);
    	/* Init Group 0: Channel and Backgroung Request*/
    	XMC_VADC_GROUP_Init(ADC_Group_0, &ADC_Group_handle);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_0, 7, &ADC_G0CH7_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_0, 6, &ADC_G0CH6_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_0, 5, &ADC_G0CH5_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_0, 4, &ADC_G0CH4_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_0, 3, &ADC_G0CH3_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_0, 0, &ADC_G0CH0_config);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 0, 0);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 0, 3);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 0, 4);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 0, 5);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 0, 6);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 0, 7);
    	/* Init Group 1: Channel and Backgroung Request */
    	XMC_VADC_GROUP_Init(ADC_Group_1, &ADC_Group_handle);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_1, 0, &ADC_G1CH0_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_1, 1, &ADC_G1CH1_config);
    	XMC_VADC_GROUP_ChannelInit(ADC_Group_1, 6, &ADC_G1CH6_config);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 1, 0);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 1, 1);
    	XMC_VADC_GLOBAL_BackgroundAddChannelToSequence(VADC, 1, 6);
    	/* Enable Background Conversion */
    By leaving out single functions I could figure out that the function call XMC_VADC_GLOBAL_INIT() will cause the error, and inside this function the call to XMC_VADC_GLOBAL_EnableModule().

    Without the code optimization the program works.
    Also, when I go through the main step by step with a debugger and I step over the ADC_initialize function, the code works. This must be some kind of timing problem.

    Is this an error by the XMC library? Any suggestions to fix this?

    Edit: Okay fixed it. Problem was that we called an ADC function, some time after the initialization. But we have to wait 200us after initialization. Without code optimization it worked because the code took long enough.
    I added a for loop which fixes the problem.
    Last edited by oliver.blasius; Aug 15th, 2017 at 03:47 AM.

+ Reply to Thread

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.