I don't understand how to use the function printf in S32 Design Studio for ARM Version 2.2

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I don't understand how to use the function printf in S32 Design Studio for ARM Version 2.2

6,491 Views
p_decesare
Contributor III

Hi,

I have some problems with the function Printf. I include the library <stdio.h> in my file main.c. The idea of my code is to turn on and off a green led. When I debug my code, I want to see on comsole the word: Green.

Here my code:

#include "S32K144.h" /* include peripheral declarations S32K144 */
#include <stdio.h>

int main(void)
{
PCC->PCCn[PCC_PORTD_INDEX] = 0x40000000;
PORTD->PCR[15] = 0x00000100;
PTD->PDDR = 0x00008000; /*output*/


for(;;) {
PTD->PDOR = 0;
PTD->PDOR = 0x00008000;
printf("Green");
}

return 0;
}

Excuse me for the trivial question, but I'm a begginer with the embedded system.

I hope that someone could help me.

Thanks for your availability

Tags (3)
0 Kudos
11 Replies

4,805 Views
tzeng015
Contributor II

hi jiri_kral
I have the same problem and the printf function is also can't work well.

Please see the attach file .

thank you

tzeng015 

0 Kudos

1,660 Views
Mehul_Patel_NXP
NXP Employee
NXP Employee

Hi, @tzeng015 , 

 

Sorry, checking here. If the issue was resolved. 

 

Thank you. Best regards. 

 

- Mehul Patel 

0 Kudos

6,297 Views
peter_thompson
Contributor I

I'm also trying to get printf to work, but it isn't working.

Using S32K148EVB, connected via USB to laptop with Win10 with S32 design studio (just updated to latest). 

The code:

int main(void)
{
PCC->PCCn[PCC_PORTD_INDEX] = 0x40000000;
PORTD->PCR[15] = 0x00000100;
PTD->PDDR = 0x00008000; /*output*/


for(;;) {
PTD->PDOR = 0;
PTD->PDOR = 0x00008000;
printf("Green\n");
}

return 0;

}

Using the library Ewl_C Debugger Console. 

In theory, this should be printing "Green" continuously on the debug console, but I'm not seeing anything.

0 Kudos

6,297 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

the printf output is shown in semihosting console: 

pastedImage_1.png

If console is not visible for some reason - you can open it in console menu: 

pastedImage_2.png

Hope it helps. 

Jiri 

0 Kudos

6,297 Views
peter_thompson
Contributor I

Odd. I just created new example, set the library to ewl_c debugger, added include <stdio.h> and the printf worked.

So, I think I’m good for now. Thanks for your help.

Cheers, Peter

0 Kudos

6,297 Views
peter_thompson
Contributor I

Hi Jiri,

I am not seeing the text “Green” on the debugger console, nor the regular console. I have tried also to use Teraterm to listen for the text, but I am not seeing anything. I have the ewl_c Debugger Console set for Libraries support.

I downloaded and ran the LPUART project – this communicates fine with Teraterm.

Anything else I should check?

Cheers, Peter

0 Kudos

6,297 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

you need to use lib C with Debugger console: 

pastedImage_1.png

printf output is shown in Semihosting console.

Hope it helps. 

Jiri 

0 Kudos

4,785 Views
tzeng015
Contributor II

Hi 

ewl_C Debugger Console ??
I can’t see it .

 

0 Kudos

1,886 Views
psarkar
Contributor I

Were you able to resolve the issue? I am facing the same issue and am unable to see 'ewl_c debugger' as in the snapshot shared here.

0 Kudos

6,296 Views
p_decesare
Contributor III

Hi Jiri Kral

thank you for your answer. I don't resolve the problem.

Here two figures. 

I follow your advice, in fact I set the option of Libraries Support. But at the Console I don't see the word Red.
Can help me?

Thank you for your availability.

debug1.JPGdebug2.JPG

0 Kudos

6,296 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

sprintf is for printing into string (memory). Try to use printf instead. 

Jiri 

0 Kudos