cancel
Showing results for 
Search instead for 
Did you mean: 

Code Examples

SaGa_4641021
New Contributor II

Hi

I am using a code example (CE218964 - PSoC 6 MCU RTC Daily Alarm). the printf() functions does not print to serial port.

I had the same issue with all the code examples that use printf(). I had to replace it with UART_put or UART_putstring().

I read many threads to find a solution, for example changing heap size, or adding "fflush(stdout);". None of those proposed solutions work.

Any help ?

also what does the heap have to do with the operation of printf() ?

thanks

0 Likes
1 Solution
Hari
Moderator
Moderator

Hi @SaGa_4641021 

 

The issue is in the stdio_use.h. Please replace the SCB instance in lines 166 and 167 to SCB5 instead of SCB0 as we are using SCB5 in this project. This should enable printf in your project. 

Hari_0-1633506599601.png

 

 

Best regards, 
Hari

View solution in original post

6 Replies
Hari
Moderator
Moderator

Hi @SaGa_4641021 

 

Can you let us know what device you are using? I tried the CE at my end on the 062-BLE kit and it is working as expected. Also, do not replace or delete the stdio_user.h file if prompted by PSoC Creator. 

 

The printf() function uses dynamic memory allocation. This is why we need to allocate sufficient heap memory for the code to work. 

 

Best regards, 
Hari

0 Likes
SaGa_4641021
New Contributor II

Hi Hari

Thanks for the help.

 I am using PSoC63 (CYBLE-416045-02, the SMT-43 module).

I started with an example code from PSoC and I approved the recommend removal of unused files by PSoC Creator. Which files do I have to include so that I would make the printf() work ?

thanks

0 Likes
SaGa_4641021
New Contributor II

i added a simple one line code to show my configuration

 

0 Likes
Hari
Moderator
Moderator

Hi @SaGa_4641021 

 

The issue is in the stdio_use.h. Please replace the SCB instance in lines 166 and 167 to SCB5 instead of SCB0 as we are using SCB5 in this project. This should enable printf in your project. 

Hari_0-1633506599601.png

 

 

Best regards, 
Hari

View solution in original post

SaGa_4641021
New Contributor II

Hi Hari

It worked, thank you.

One more question, how would I know which SCB is chosen ? so that in the future, I can modify the stdio_user.h

thanks again

0 Likes
Hari
Moderator
Moderator

Hi @SaGa_4641021 

 

You can identify the SCB block from the pins tab in PSoC creator. Once you select the pin to be used as UART Tx (or Rx) it will show you the corresponding SCB block in the drop down menu - 

Hari_0-1633585949264.png

Best regards, 
Hari