+ Reply to Thread
Results 1 to 3 of 3

Thread: XMC1100 UART Bug

  1. #1
    New Member New Member JJLK is on a distinguished road
    Join Date
    Mar 2020
    Posts
    2
    Points
    45

    XMC1100 UART Bug

    Hello everyone,

    I have a very weird Issue with the UART of the XMC 2 Go.

    When I manually inline a function ; which calls "UART_Transmit"; into the "main" function,
    the transmission of the message to the computer works.
    If I extract the code into a separate function --"TimeTasks_run" -- then the transmission fails and
    inserts some seemingly random Characters.
    This should definitely not happen.
    I have attached the complete zipped DAVE project.

    In case you don't want to download the zip archive, but rather generate the app on you own,
    just generate a XMC-2-Go project with a default 'UART' app, rename the instance to 'DEBUG_UART' and change the Baudrate to 115200.
    Then replace the code in the 'main.c' file, with the code from here.
    You can then switch the configurations by inlining the code from "TimeTasks_run".

    Please let me know if you can replicate the issue, maybe with other devices, the AA, or the AB Step.
    I don't know what step I have, as there is just a "B" or "BS" at the end of the engravings.

    I have Tested it with two devices:
    - 3D Magnetic Sensor 2 Go with Chip Engraving: XMC1100F064BS
    - TLI4970 2 Go with Chip Engraving: XMC1100F064B

    Uart Baud: 115200
    Uart Config: 8N1


    This is
    Code:
    #include <DAVE.h>
    
    uint32_t volatile tick_count;
    
    extern void SysTick_Handler(void){
    	tick_count++;
    }
    
    uint32_t overflow_save_diff_u32(uint32_t minuend,
    		uint32_t subtrahend){
    	uint32_t diff_time;
    	if (minuend < subtrahend) {
    		diff_time = 0xFFFFFFFF - subtrahend + minuend;
    	}else{
    		diff_time = minuend - subtrahend;
    	}
    	return diff_time;
    }
    
    bool UpdateTime(uint32_t *last_ticks){
    	if(tick_count != *last_ticks){
    		*last_ticks = tick_count;
    		return true;
    	}else{
    		return false;
    	}
    }
    
    void TimeTasks_run(uint32_t last_ticks);
    
    int main(void){
    	uint32_t last_ticks = 0;
    	DAVE_STATUS_t status;
    	
    	status = DAVE_Init();
    	SysTick_Config(SystemCoreClock/1000);
    	
    	if(status != DAVE_STATUS_SUCCESS){
    		while(true){}
    	}
    
    	while(true){
    		if(UpdateTime(&last_ticks)){
    			TimeTasks_run(last_ticks);
    
    //			static uint32_t remembered_time_8_ms;
    //
    //			uint8_t message[] = "Hello World Out There This is crazy\n";
    //
    //			if(overflow_save_diff_u32(last_ticks, remembered_time_8_ms) >= 8){
    //				remembered_time_8_ms = last_ticks;
    //				UART_STATUS_t status = UART_Transmit(&DEBUG_UART, message, sizeof(message));
    //				if(status != UART_STATUS_SUCCESS){
    //					while(true){}
    //				}
    //			}
    		}
    	}
    }
    
    void TimeTasks_run(uint32_t last_ticks){
    	static uint32_t remembered_time_8_ms;
    
    	uint8_t message[] = "Hello World Out There This is crazy\n";
    
    	if(overflow_save_diff_u32(last_ticks, remembered_time_8_ms) >= 8){
    		remembered_time_8_ms = last_ticks;
    		UART_STATUS_t status = UART_Transmit(&DEBUG_UART, message, sizeof(message));
    		if(status != UART_STATUS_SUCCESS){
    			while(true){}
    		}
    	}
    }
    This is the output that i receive on my serial terminal in case of the code being in a separate function.
    Code:
    The  ]Hello World Out TheQ7 ] Hello World Out The  ]Hello World Out The  ]Hello World Out The  ]
    Hello World Out The  p7q7Hello World Out The  x7y7Hello World Out The 77Hello World Out The  77Hello World Out The 77Hello World Out The
    Best Regards, Jakov
    ?????
    Last edited by JJLK; Mar 23rd, 2020 at 03:28 PM.

  2. #2

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

    The message array is defined in the stack of the TimeTasks_run funcion and the UART_Transmit() function is not blocking, exiting the TimeTasks_run after triggering the start of the transmission. Therefore depending on the program flow, i.e. stack usage, you will see strange characters being output.

    You can try declaring the message array as static.


    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 JJLK is on a distinguished road
    Join Date
    Mar 2020
    Posts
    2
    Points
    45

    Issue Resolved

    Hello Jesus,

    Thank you very much ! You are spot on right.
    I am seriously wondering how i could have missed that one.

    Best Regards,
    Jakov

+ 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.