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;
}
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.
If choose Semihost console (default), it will output in "Console " window of MCUXpresso IDE.
BR
Alice
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.
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