renga92
Member level 5
hello everyone,
i am doing a project on countdown timer (0 - 99) min and i am also counting the total hours of its working time. i am saving the no of hours and mins in eeprom for every count down of the timer.
i ran into a problem when i want to increment value greater than 255 (no of hours) and i end up getting a weird value[ the increment function fine till i shutdown the timer and turn it on,after turning it on i get weird values ]. i got the reason for getting that weird value...
if the no is 312 after saving it to eeprom. then i did turn it off and then i turned it on ,checked the value stored in the eeprom. it was still 312.
then i set the timer for any time after turning on (for example : 4 mins)
after 4 mins value turns out to be 057
the reason was that
312 binary equivalent - 1 00111000
57 binary equivalent - 0 00111001
so the ninth bit is set in the first bit.
the reason is i am working with 8 bit controller...
now my question is
1)how to work with nos greater than 255 ?
2)will that overflow in w register call any stack or will it cause any interrupt ?
i am asking this because i am using 5 to 6 functions which might also occupy most of the stack all the time...
please help me to solve this problem..
thanks in advance
renga92
i am doing a project on countdown timer (0 - 99) min and i am also counting the total hours of its working time. i am saving the no of hours and mins in eeprom for every count down of the timer.
i ran into a problem when i want to increment value greater than 255 (no of hours) and i end up getting a weird value[ the increment function fine till i shutdown the timer and turn it on,after turning it on i get weird values ]. i got the reason for getting that weird value...
if the no is 312 after saving it to eeprom. then i did turn it off and then i turned it on ,checked the value stored in the eeprom. it was still 312.
then i set the timer for any time after turning on (for example : 4 mins)
after 4 mins value turns out to be 057
the reason was that
312 binary equivalent - 1 00111000
57 binary equivalent - 0 00111001
so the ninth bit is set in the first bit.
the reason is i am working with 8 bit controller...
now my question is
1)how to work with nos greater than 255 ?
2)will that overflow in w register call any stack or will it cause any interrupt ?
i am asking this because i am using 5 to 6 functions which might also occupy most of the stack all the time...
please help me to solve this problem..
thanks in advance
renga92