please check console log, when use chprintf

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
jslee
Posts: 15
Joined: Thu Jun 11, 2020 9:54 am
Has thanked: 3 times

please check console log, when use chprintf

Post by jslee »

Hello, somebody help me please?

Below is my example code.

Code: Select all

uint64_t tempVal  = 315989888600;
chprintf(chp1, "\t tempVal : %d %03d\r\n", (tempVal / 1000), (tempVal % 1000));
uint64_t tempVal2 = tempVal % 1000;
chprintf(chp1, "\t tempVal2: %03d\r\n", tempVal2);

And I got console log like below

Code: Select all

tempVal : 315989888 000
tempVal2: 600


I was expecting
tempVal : 315989888 600
but, got
tempVal : 315989888 000

What am I doing wrong?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: please check console log, when use chprintf

Post by Giovanni »

Hi,

Do not pass uint64_t to chprintf(), cast it to uin32_t or assign values to 32 bits variables beforehand.

Giovanni
jslee
Posts: 15
Joined: Thu Jun 11, 2020 9:54 am
Has thanked: 3 times

Re: please check console log, when use chprintf

Post by jslee »

Giovanni wrote:Hi,

Do not pass uint64_t to chprintf(), cast it to uin32_t or assign values to 32 bits variables beforehand.

Giovanni


Aright. No more problem. Thank you
Post Reply