User Input in MCUXpresso IDE

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

User Input in MCUXpresso IDE

1,946 次查看
caden013
Contributor III

Hi all,

I am trying to use the function GETCHAR() in the MCUXpresso IDE to accept user input, but I don't see how this is possible. The terminal does not allow anything to be typed inside of it, and the console appears to not accept any input. I am running the example project lpadc_interrupt.c, provided by NXP, and it has the function GETCHAR() in it. 

Here is the part of the code that has this function in it:

PRINTF("Please press any key to get user channel's ADC value.\r\n");
while (1)
{
GETCHAR();
LPADC_DoSoftwareTrigger(DEMO_LPADC_BASE, 1U); /* 1U is trigger0 mask. */
while (!g_LpadcConversionCompletedFlag)
{
}
PRINTF("ADC value: %d\r\nADC interrupt count: %d\r\n",
((g_LpadcResultConfigStruct.convValue) >> g_LpadcResultShift), g_LpadcInterruptCounter);
g_LpadcConversionCompletedFlag = false;
}

0 项奖励
回复
3 回复数

1,933 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello aden013,

You can use Hello World deme, and choose UART console ,then use a serial terminal of PC

to receive/send character with MCU.

Alice_Yang_1-1623134733309.png

If choose Semihost console (default), it will output in "Console " window of MCUXpresso IDE.

 

BR

Alice

 

1,537 次查看
prakash3
Contributor I

Hi Team,

In MCU xpresso console, I am trying to give user input to execute different task which (SCANF / GETCHAR) is used inside infinite loop.  At first time scanf is waiting for user input and getting executed the related task. After executed, its returning back to infinite loop. now scanf is not waiting for until user input. its taking automatically some garbage value and executing. can anyone help on this issue.

标记 (1)
0 项奖励
回复

1,533 次查看
ErichStyger
Specialist I

It looks you are using semihosting?

Keep in mind that the way of getting input with semihosting and the standard library is non-standard. Even worse, it depends on the debug probe (and version) used.

I recommend you have a read at an article I wrote a while back here: https://mcuoneclipse.com/2023/03/09/using-semihosting-the-direct-way/

It provides a way and test code to write and read data from the debugger console, including file I/O.

I hope this helps,

Erich

0 项奖励
回复