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
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.
Hi,
the printf output is shown in semihosting console:
If console is not visible for some reason - you can open it in console menu:
Hope it helps.
Jiri
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
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
Hi,
you need to use lib C with Debugger console:
printf output is shown in Semihosting console.
Hope it helps.
Jiri
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.
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.
Hi,
sprintf is for printing into string (memory). Try to use printf instead.
Jiri