- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello guys,
Thought my task would be easy, but I cant get any keyboard entry with my PSoC 5LP.
I tried scanf and getchar, nothing is working. I thought, with getchar() my code would stop until I press any key, but my code somehow just skips the command.
Any experiences with Creator and keyboard entries?
Thanks in adance,
Alexander
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Alexander,
a bit more information required: What kind of Keyboard are you using?
Which PSoC board? CY8CKIT-050?? Any external connections made? Which??
Project workspace Bundle available?
And: getchar() is afaik an operating system call and needs some support in GCC to work correctly.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, firstly I want something like "press 1 to go to options, press 2 to ..." Just to choose between different options. Secondly I want to type in some values for my measurement. Just using the keyboard of my computer. In the future I want to connect some external keypad to my PSoC CY8CKIT-058 (building up a handheld device), but currently it would be sufficient just to use the computer keyboard.
What do you mean by support of GCC to get it working.
Regards, Alexander
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply, but the current problem is just, to type something in with my computer key board and show it via UART. If i try some code with getch() or scanf() with an simple C compiler, everthing is fine. But by using the commands in Creator, no success.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have a look into the CY8CKIT-059 (Typo?) the kitprog's usb-uart bridge uses pins P12_7 and P12_6, connect your UART to them.
Then you will read with UART_GetChar() from your PuTTY interface.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes -059 is right. It was never a problem with the connection or the UART itself. Maybe my problem explanation wasnt clear enough, sorry for that. Found out that my problem was the loop, I thought UART_GetChar() would wait for an keyboard input. Now I configured my loop, so problem one is solved. I used the switch-case-procedure for my option selection in the way of "press 1 to go to options, press 2 to ..."
But now comes the second problem. I am not able to type in some values. For example want to type in a frequency value of 30000 Hz via my keyboard. Any ideas??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Usual approach is: Collect all chars (!=0) in a buffer. When receiving a terminator as \n or \r insert a 0x00 into the buffer and your input string is ready. Challenge is to allow for backspaces. Remember that PuTTY is able of processing VT100 cursor positioning commands. There is always something to program...
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont understand a word, do you have some code pieces?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I look into www I always find scanf() for keyboard inputs. Works fine with every C compiler. Except Creator, there must be some trick to use scanf() in Creator. Thought it is basic C ?!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
scanf() is there for you and does work, but your problem seems to be to get the string to scan. In the embedded world there is no default input device, you have to provide that.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ok, so the following example should work. Am i right with the code guys?
int i;
scanf("%d",&i); //my typed value is stored in i
sprintf(TransmitBuffer, "Eingabe: %d", i);
UART_1_PutString(TransmitBuffer); //i is shown via UART on my Putty.
So sprintf and UART stuff works fine, on my screen I just see: "Eingabe:0" I am not able to type something in, do I need a loop or where is my mistake?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
scanf() reads from a device named stdin supported by an operating system. Since you have got none, you need to use another member of the scanf-family: sscanf(). Have a look into the C-manual here. So what you need at first is a means to get the characters you type into PuTTY which are sent to your UART into a string. Use this string with sscanf() to convert the string to the required value.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Understood, but my question is exactly how to get the characters I typed into putty via UART to my psoc.
Maybe a loop with getchar() where psoc can assemble the single characters to a whole value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The answer is exactly what I wrote in the post you commented with "I dont understand a word".
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
oh ok 😉 thanks, I will try it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is some information on using C and programming Psoc types of Computers. http://www.cypress.com/blog/psoc-creator-news-and-information/matts-tips-embedded-programming-c-begi...