Page 1 of 1
How can I print an Integer
Posted: Tue Jun 30, 2015 3:05 pm
by GianlucaLaManna
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
Re: How can I print an Integer
Posted: Tue Jun 30, 2015 3:09 pm
by Giovanni
GianlucaLaManna wrote:I tried to use chprintf, but not working.
Define "not working".
Giovanni
Re: How can I print an Integer
Posted: Tue Jun 30, 2015 3:22 pm
by GianlucaLaManna
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
Re: How can I print an Integer
Posted: Tue Jun 30, 2015 3:26 pm
by Giovanni
Is the "Output Formatter" component included in your project? chprintf is included there, it requires ChibiOS too.
Giovanni
Re: How can I print an Integer
Posted: Tue Jun 30, 2015 3:36 pm
by GianlucaLaManna
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?
Re: How can I print an Integer
Posted: Tue Jun 30, 2015 3:54 pm
by Giovanni
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
Re: How can I print an Integer
Posted: Tue Jun 30, 2015 3:57 pm
by GianlucaLaManna
Ok, but in the demo for my board using only chnWriteTimeout. Thanks anyway.
Gianluca.
[Solved] How can I print an Integer
Posted: Tue Jul 07, 2015 11:47 am
by GianlucaLaManna
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.