??? 06/25/05 23:11 Read: times |
#95922 - The logic seems good Responding to: ???'s previous message |
Adam, your logic seems sound. But you give us no information where you think it is failing. If you can post the code you are using, that might give us a better insight into what the issue is. In the meantime, check a few things - 1/ try your code without interrupts - load the timer, set it to run then sit in a loop waiting for the overflow bit to be set. This removes the complication of interrupts if you're new to this. It will also prove your basic logic. 2/ if you get the above working, then its back to trying interrupts. Firstly just have the interrupt code toggle the port pin - keep it simple first time up. Remember you have to enable both the EA bit and the timer interrupt enable bit in the IE register. Another gotcha is declaring a local variable in an interrupt routine - locals are only created when entering the routine and destroyed when you leave - no good for storing a flag! You must declare the flag variable as 'static' - that way the variable is allocated some ram and is not trashed. For example: static char flag_var=0; I think I've covered the usual traps for young players! Hope this helps. |