microcontroller - Assembly - using more than 2 buttons for interrupts? -
i using stk200 board atmega8535 microcontroller. use int0 , int1 buttons external interrupts, in order initialize int0 have set bit 6 1 , intialize int1 have set bit 7 1, there no more space initialize other buttons.
i have been told lecturer possible use more buttons cause interrupts above knowledge required year studying (1st year software engineering).
without interrupts, have no idea how handle buttons. need either suggestions how handle buttons or how use more buttons interrupts.
there way handling buttons(different interrupts), of course interrupts best, if don't have external interrupt pins left, use this. method polling pin have connected button. i'll post code implementation in asm 8051, can understand better. hope helps:
;assume have connected button p1.1
org 00h jb p1.1,$ ;wait hold button jnb p1.1,$ ;wait button unhold ;perform end as can see in second line of code check if button pressed(assuming button active low of course), if wasn't stay there, if pressed jump line 3 wait until button unholded. if don't wait until btn unholded microprocessor perform ehat want lots of times 1 press btn.the cause of simple:the frequency of mp(could 12mhz) faster frequency of finger pressing button,or,in other words: can press button fast can mp faster you:). note: interrupts better simple reason: don't have polling.
hope understand.
Comments
Post a Comment