How can I print an Integer

ChibiOS public support forum for topics related to the STMicroelectronics SPC56x family of automotive micro-controllers.
GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm
Location: Palermo, Italy

How can I print an Integer

Postby GianlucaLaManna » Tue Jun 30, 2015 3:05 pm

Hello.
I use the board SPC560P-DISP.
How can I print an Integer with Tera Term through a serial connection?
I use the function chnWriteTimeout to print a string. So:

Code: Select all

chnWriteTimeout(&SD1, (uint8_t *)"Hello World!\r\n", 14, TIME_INFINITE);

But an Integer?
I tried to use chprintf, but not working.
thanks.

Best regards
Gianluca

User avatar
Giovanni
Site Admin
Posts: 11307
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: How can I print an Integer

Postby Giovanni » Tue Jun 30, 2015 3:09 pm

GianlucaLaManna wrote:I tried to use chprintf, but not working.


Define "not working".

Giovanni

GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm
Location: Palermo, Italy

Re: How can I print an Integer

Postby GianlucaLaManna » Tue Jun 30, 2015 3:22 pm

Yes. It does not recognize the function chprintf. I included the header chprintf.h

Code: Select all

uint32_t number=25;

chprintf(&SD1, "%u \n\r", number);


The error is:

Code: Select all

main.c:(.text_vle.main+0x10c): undefined reference to `chprintf'
collect2: ld returned 1 exit status
make: *** [build/out.elf] Error 1


Gianluca

User avatar
Giovanni
Site Admin
Posts: 11307
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: How can I print an Integer

Postby Giovanni » Tue Jun 30, 2015 3:26 pm

Is the "Output Formatter" component included in your project? chprintf is included there, it requires ChibiOS too.

Giovanni

GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm
Location: Palermo, Italy

Re: How can I print an Integer

Postby GianlucaLaManna » Tue Jun 30, 2015 3:36 pm

Sorry, I don't know and I don't understand.

This is my include in my code:

Code: Select all

#include "components.h"
#include "adc_lld_cfg.h"

#include "pwm_lld_cfg.h"
#include "icu_lld_cfg.h"



I have to include something else? Or enable some option in the configuration.xml file?

User avatar
Giovanni
Site Admin
Posts: 11307
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: How can I print an Integer

Postby Giovanni » Tue Jun 30, 2015 3:54 pm

Please look at all the ChibiOS demos included in SPC5Studio, all of them use chprintf(). You could start from one of those demos for your experiments.

Giovanni

GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm
Location: Palermo, Italy

Re: How can I print an Integer

Postby GianlucaLaManna » Tue Jun 30, 2015 3:57 pm

Ok, but in the demo for my board using only chnWriteTimeout. Thanks anyway. :)

Gianluca.

GianlucaLaManna
Posts: 25
Joined: Fri Mar 13, 2015 12:12 pm
Location: Palermo, Italy

[Solved] How can I print an Integer

Postby GianlucaLaManna » Tue Jul 07, 2015 11:47 am

I used os-less.
Now I use chibios.

I solved so:

Code: Select all

chprintf((BaseSequentialStream *)&SD1, "Value of number is:  %d", number);


Thanks.

Best regards
Gianluca.


Return to “SPC56x Support”

Who is online

Users browsing this forum: No registered users and 1 guest