How to use scanf to get values from the keyboard

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to use scanf to get values from the keyboard

337 次查看
Transidico
Contributor III

Good morning,

I am trying to use the Hello World demo to see how the terminal works using mcxc242.

I am using teraterm. I can see PRINTF correctly, but GETCHAR() or SCANF() to send values from the keyboard does not seem to work.

Is there anything I need to enable?

Thank you for your reply.

0 项奖励
回复
5 回复数

259 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Transidico 

Please test using the SDK demo hello_world. I have tested it on the FRDM-MCXC242 board, and the GETCHAR() function works properly.
Please choose UART console on SDK Debug Console:
Alice_Yang_1-1757477478093.png

 

If you still have issues, please check your hardware connections—specifically, whether the UART RX pin is connected correctly.
If you are using your own custom board, you may also send us your schematic for reference. If you are using an NXP DEMO board, please take a photo of the jumpers, I help you check. 
 

Thank you. 

 

BR

Alice

 

BR

Alice

0 项奖励
回复

320 次查看
Transidico
Contributor III
It works on the integrated console, but not on Teraterm or other Terminal.
0 项奖励
回复

300 次查看
ErichStyger
Specialist I

Are you using the UART or semihosting for your input/output?

Typically, most terminal views do not support semihosting, but built-in terminal views in the IDE might support it.

And if using semihosting, most implementation do only implement output, no input. If you want input, you have to use a library like this one: https://mcuoneclipse.com/2023/03/09/using-semihosting-the-direct-way/

I hope this helps,

Erich

0 项奖励
回复

292 次查看
Transidico
Contributor III

Good morning,

With semihost, both input and output work via the mcxpresso console, whereas if I enable it with uart, I see it working on the teraterm terminal only in output, not in input. I am not using the external debugger, only USB.

I don't really care which mode I choose (UART or semihost), the important thing is that I can get the characters from the keyboard via Teraterm.

What should I do? Is it possible without an external debugger?

Thanks in advance, bye.

 

 

 

Translated with DeepL.com (free version)

0 项奖励
回复

290 次查看
ErichStyger
Specialist I

Yes, you can read from the UART console too.

Can you check your _read() function? This is where it gets the data.

0 项奖励
回复