"chprintf" , STM32F303 Discovery Topic is solved

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
bennydeber
Posts: 5
Joined: Thu Jul 20, 2017 6:25 pm
Has thanked: 1 time
Been thanked: 1 time

"chprintf" , STM32F303 Discovery

Post by bennydeber »

Hi,
I 'm using a STM32F303 Discovery Board and I have done a project that works, but I would like to use chprintf and read the datas on terminal:

Code: Select all

for (i=0;i<=8;i++){
       percentage = 500+i*1000;

   chprintf(chp, "PERCENTAGE -> %d\n\r",percentage/100);
        chThdSleepMilliseconds(1000);

                     }


I have included "chprintf.h",the port is correct and I use STLink V2 to print data on the terminal. I have to change something in the makefile?


Thank you all.

PS.
I have also tried this project (http://www.playembedded.org/blog/en/201 ... -and-mems/) and the demo "USB_CDC", but both give me a lot of errors. As playembedded suggests, I connect the board through the User USB: at first my PC didn't recognize the device, after installing STM32 Virtual COM Port Driver, it seems to recognize it.
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: "chprintf" , STM32F303 Discovery

Post by Giovanni »

Hi,

chprintf() must also be included in the makefile togethr with memstream.c, see any demo that uses it.

Giovanni
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: "chprintf" , STM32F303 Discovery

Post by RoccoMarco »

Hi,
which version of ChibiOS are you using?
bennydeber
Posts: 5
Joined: Thu Jul 20, 2017 6:25 pm
Has thanked: 1 time
Been thanked: 1 time

Re: "chprintf" , STM32F303 Discovery

Post by bennydeber »

Giovanni wrote:Hi,

chprintf() must also be included in the makefile togethr with memstream.c, see any demo that uses it.

Giovanni


I have modified my makefile , but the situation doesn't change:

Code: Select all

CSRC = $(STARTUPSRC) \
       $(KERNSRC) \
       $(PORTSRC) \
       $(OSALSRC) \
       $(HALSRC) \
       $(PLATFORMSRC) \
       $(BOARDSRC) \
       $(TESTSRC) \
       $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
       $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
       main.c




RoccoMarco wrote:Hi,
which version of ChibiOS are you using?


the version is 17.7.
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: "chprintf" , STM32F303 Discovery

Post by steved »

There are three places in the makefile which need updating:
1. The list of included make files
2. The list of source files (which you have done)
3. The list of 'include' directories

If you are using 17.1.6, they are:

Code: Select all

1. include $(CHIBIOS)/os/hal/lib/streams/streams.mk
2.        $(STREAMSSRC) \         # Adds all needed source files
3. $(STREAMSINC)

Earlier versions have similar requirements, but they may be expressed differently
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: "chprintf" , STM32F303 Discovery

Post by RoccoMarco »

The article has been written for 161, and inclusion was performed in a different way (as Steved said).

An error in demo from playembedded... ok it is possible. An error in USB-CDC demo is quite strange.

Can you post here the error you are receiving with USB_CDC? I will give a little try to the playembedded demo meanwhile.
bennydeber
Posts: 5
Joined: Thu Jul 20, 2017 6:25 pm
Has thanked: 1 time
Been thanked: 1 time

Re: "chprintf" , STM32F303 Discovery

Post by bennydeber »

RoccoMarco wrote:The article has been written for 161, and inclusion was performed in a different way (as Steved said).

An error in demo from playembedded... ok it is possible. An error in USB-CDC demo is quite strange.

Can you post here the error you are receiving with USB_CDC? I will give a little try to the playembedded demo meanwhile.



Sorry, I was wrong. USB_CDC starts, but the terminal is like this:

Image
bennydeber
Posts: 5
Joined: Thu Jul 20, 2017 6:25 pm
Has thanked: 1 time
Been thanked: 1 time

Re: "chprintf" , STM32F303 Discovery-RESOLVED

Post by bennydeber »

Ok, USB_CDC works now:

I downloaded the latest version of ST-Link Utility and I did the firmware upgrade.
Now when I connect my board through USB USER and USB ST-LINK in device manager there are two COMs:
Image.

The next steps are disconnect USB USER, run OpenOCD on ST-Link V2 and flash, play and select "COM7" as port in terminal settings.
After this, I connect the second USB (in this way both usb are connected to my pc) and after I press Enter button.
Now I can choose one of the command (for example "help","exit" and so on...) and so I can see the output on the terminal :)
Post Reply