Post Go back to editing

getchar and scanf functions in MAX32655FTHR with CFS/VSC

Thread Summary

The user is experiencing issues with getchar() and scanf() functions when trying to modify SD-ADC settings on the MAX32655FTHR through the VS Code serial console. The final answer confirms that these functions should work with the Maxim SDK's stdio.c implementation, which redirects standard I/O to the UART. The user needs to ensure the serial console sends a carriage return (CR) when Enter is pressed, as the _read() function waits for CR to signal the end of input.
AI Generated Content
Category: Software
Product Number: MAX32655
Software Version: 1.1.0

Hi,

I am newcomer for MAX32655 and trying to communicate with SD-ADC using MAX32655FTHR.

My program works almost OK and I am thinking the program to work modifying SD-ADC's setting through VS code serial console.

printf function works OK and its characters appear on the serial console.

But if I use getchar function in my code, the character puts to the serial console can't obtained in my code.

Can getchar and scanf use in the environment and could you suggest me how to use these function if it is possible?

Regards,

Satoru

Parents
  • Hi Satoru,

    The Maxim SDK (msdk) already includes a stdio.c implementation that redirects standard I/O functions like printf(), scanf(), and getchar() to the UART interface. This file provides the necessary low-level _read() and _write() functions, allowing seamless communication through the serial console.

    By default, the _read() function waits for a carriage return (\r) to signal the end of input. This means that:

    • You do not need to modify _read() yourself — it's already implemented correctly in the SDK.

    • UART must be initialized properly using MXC_UART_Init() — it's already initialized correctly because you can see the printf() outputs.

    • Your serial console (e.g. Serial Monitor extension by Microsoft in VS Code) must send at least a carriage return (CR) when you press Enter.

      • Sending CR+LF also works, but CR alone is sufficient.

    Once these conditions are met, scanf() and getchar() will function as expected, allowing interactive input from the serial terminal.

    Kind regards,

    Haluk

Reply
  • Hi Satoru,

    The Maxim SDK (msdk) already includes a stdio.c implementation that redirects standard I/O functions like printf(), scanf(), and getchar() to the UART interface. This file provides the necessary low-level _read() and _write() functions, allowing seamless communication through the serial console.

    By default, the _read() function waits for a carriage return (\r) to signal the end of input. This means that:

    • You do not need to modify _read() yourself — it's already implemented correctly in the SDK.

    • UART must be initialized properly using MXC_UART_Init() — it's already initialized correctly because you can see the printf() outputs.

    • Your serial console (e.g. Serial Monitor extension by Microsoft in VS Code) must send at least a carriage return (CR) when you press Enter.

      • Sending CR+LF also works, but CR alone is sufficient.

    Once these conditions are met, scanf() and getchar() will function as expected, allowing interactive input from the serial terminal.

    Kind regards,

    Haluk

Children
No Data