XMC1100 UART Bug

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

cross mob
lock attach
Attachments are accessible only for community members.
User19222
Level 1
Level 1
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

#include

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.

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
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
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
0 Likes
User19222
Level 1
Level 1
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
0 Likes