hsa.a
Junior Member level 3
- Joined
- Dec 15, 2016
- Messages
- 30
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 6
- Activity points
- 232
hi, i wanted to know if my INITIAL loop is wrong method to check how that how many times the button has been pressed?
- - - Updated - - -
Hi Brian,
I beleive that I am already using timer0 for the delays in blinking. as far as the interrupt check is concerned, I want it to be time independent. therefore, I am not sure why I should use the timer for it
- - - Updated - - -
but i dont want it to be time dependent. I want it to work as a counter i.e, for example if I have stored 2 in R0. Each time the button is pressed it should dec the register by one and compare to the given value. i have tried to do the similar thing in my "INITIAL" loop. However, there is some mistake in it due to which it serialy transmits both "ON" & "OFF".
- - - Updated - - -
Hi Brian,
I beleive that I am already using timer0 for the delays in blinking. as far as the interrupt check is concerned, I want it to be time independent. therefore, I am not sure why I should use the timer for it
- - - Updated - - -
Hi,
try to set up a timer for an interrupt every about 0.25s
Follow: Timer 1 Mode - Interrupt method
https://exploreembedded.com/wiki/5.8051_Timer_programming
Use one variable/register "LED_mode":
0 = LED OFF
1 = LED blink 1Hz
2 = LED blink 2Hz
***
ISR: (pseudocode)
If LED_mode = 0 then switch OFF LED
if LED_mode = 1 then use a counter/flag and toggle LED every second interrupt
If LED_mode = 2 then toggle LED (every interrupt)
reset interrupt flags
RETI
Klaus
but i dont want it to be time dependent. I want it to work as a counter i.e, for example if I have stored 2 in R0. Each time the button is pressed it should dec the register by one and compare to the given value. i have tried to do the similar thing in my "INITIAL" loop. However, there is some mistake in it due to which it serialy transmits both "ON" & "OFF".