User Input in MCUXpresso IDE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

User Input in MCUXpresso IDE

1,068 Views
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 Kudos
Reply
3 Replies

1,055 Views
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

 

659 Views
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.

Tags (1)
0 Kudos
Reply

655 Views
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 Kudos
Reply