This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

4 switches interfacing with tm4c123gh6pz

Other Parts Discussed in Thread: TM4C123GH6PZ

Hi....

i'm interfacing the 4 switches to tm4c123gh6pz  controller using GPIO pins..4 switch for Enter,Back,up,down..

if i'l press the enter key then i can set the value using the Back,up,down key..for example initially i'm display  the default value as 1000 Hz..so i suppose to to increment the value from 1000 to 6666..after setting this value i need come back to used mode by pressing the enter key..my doubt is how to comeback to user mode after setting the value???i known this is not  the rite way to ask this question here..but i need some one help..

i have attache my code..please help me..Thanks in advance

0763.16x2 lcd.rar

  • Hi,

    I read your code - seems not very well structured - you missed the analysis phase, rushing to the coding phase. Normally what I can say in such situations: start again from the beginning, erase/forget the actual code and try to make another one, after analysis (I have done the same several times...).

    A possible solution is to use "state machine" concept for this - but unfortunately i cannot provide you code. Code could be more complicated if you have more than one parameter to set. Think about that before coding, the client could ask you such thing after the project is finished...

    Petrei

  • k thank you for your information....any sample code is their with you??..because just now i have started my journey in this field.so i need some help..please..

  • Hi..now i need some logic to go for user mode after setting the value using one switch..can i use timer for timeout??

  • Hi,

    As I said before, I cannot provide you some code (NDA agreement) but suggest a possible approach. But, you need to start from the beginning, as I said - for instance your four keys shoud be better in a timer interrupt, organized as 2x2 keyboard with two-keys rollover - i.e if two or more keys are pressed simultaneously the returned value should be the same as for no key pressed. The reason is simple - if the user play with your keys, what the software should do? You must take care about bad intentions (could be also accidental ones, even for you). TI examples are examples, for a good product/project you must take all precautions against such things. 

    As usual in many situations, the general rule is "divide et impera" i.e. divide your requirement in small steps, possible independent one of the other. For your case: one small step is normal display, no keys pressed. At this step pressing up, down, back key should do nothing; only the enter key should be active and when pressed, the next step, call it edit, should be active, with up key increasing, down key decreasing the value and enter to return to display step. Usually, this step should display also the state - for instance to blink the value modified.

    This is only one possible starting point - from this point further - your job or another division of facts - depends on your requirements/future add-ons...

    Petrei