please check console log, when use chprintf

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

Moderators: RoccoMarco, barthess

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

please check console log, when use chprintf

Postby jslee » Mon Jun 13, 2022 8:59 am

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: please check console log, when use chprintf

Postby Giovanni » Mon Jun 13, 2022 10:52 am

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

Postby jslee » Wed Jul 13, 2022 2:51 am

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


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 12 guests