Hi I have to use a 16 bit up/down counter...... I wrote the code for that in at89c51. The counting is made in external interrupt 0. The pulses are given by a linear scale. the count values are stored in mem location 50 and 51. The up counting or down counting is decided by the state of the 3.0 and 3.1 pins
counter: jnb p3.0,ru jnb p3.1,rd reti rd: push acc mov a,51h ;up counting add a,#01h jc bb sjmp aa bb: inc 50h aa: inc 51h pop acc reti ru: push acc ;down counting mov a,51h clr c subb a,#01h jc dd sjmp cc dd: dec 50h cc: dec 51h pop acc reti
Hi Erik The reason i said for going into extra hardware was that our resources are limited to the atmel family and we could go only up to the at89s8252. As i have already posted before, the 8252 does have up/down counting (DCEN) but during down counting the timer values reset to zero. please correct me if i am wrong. kannan.k