AnsweredAssumed Answered

Implement a usart1 receive interrupt without pressing a key

Question asked by costella.david on Sep 1, 2014
Latest reply on Sep 2, 2014 by costella.david

Hello Forum,

I have implemented a menu system on my app using the console

Main Menu Select A ....1   (e.g. prints Debug1)
Main Menu Select B.....2
2
     Sub Menu B Select A ......1
     Sub Menu B Select B.......2
1
 Carry out Sub Menu B Select A action....e.g print debug2
    Sub Menu B Select A ......1
    Sub Menu B Select B.......2
1

  

After selecting Main menu B by pressing '2',  I enter the sub menu from which I can select any of the sub menu options. Aften completing the sub menu action, I redisplay the sub menu to give the user the opportunity to select from it again if required. However when I press '1 ' again it takes me back into main menu '1' action where it prints Debug1. I can understand this as the usart interrupt just sees a '1' . However I want it to carry out the sub menu action.

After completing the sub menu action I think I need to make the usart1 receive interrupt think that a '2' has been pressed so that it resisplays the sub menu again. I tried the following but it doesn't seem to work.

char sub_menu_option = '2';
scanf("%c", &sub_menu_option);

Is there a way to do this or is this nonsense and is there an easier way?

Apologies if this is very convoluted but any help would be greatly appreciated.

Dave


Outcomes