How to print unsigned int always positive
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-06 9:47 AM
Posted on September 06, 2016 at 18:47
This is more of a C problem than Arm problem, here too are some people who know their C.
I am reading the value of DWT_CYCCNT; When print it via Uart, after a while it becomes negative. The most signicant bit becomes 1, but how to tell it to the compiler that it is not a sign.//the declaration
char
klaa[40];
//the code
while
(1)
{
kellopulshit = *DWT_CYCCNT;
sprintf
(klaa,
''Clock pulses %d \n''
, kellopulshit);
c=
strlen
(klaa);
HAL_UART_Transmit(&huart2,(uint8_t *) klaa,c,1000);
This discussion is locked. Please start a new topic to ask your question.
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-06 10:08 AM
Posted on September 06, 2016 at 19:08
whats the type of
kellopulshit
try %u for unsigned int
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-06 10:28 AM
Posted on September 06, 2016 at 19:28
It is unsigned int
I'll try the %u a bit later. At least it didn't give an errorOptions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-09-06 10:45 AM
Posted on September 06, 2016 at 19:45
It works, thanks.
