Using Interrup for timing
Using Interrup for timing
I am trying to build an amphour meter using PIC16F877A for which i need to read the adc once every second, not delay of 1 second. the best way i found is to use interupt to acheive this. But i am unable to understand how to do this. Can someone please explain with a simple adc read code that reads every second, the complete loop takes 1 second to execute. Is there a wait function where the code can halt till a counter equals a value?
Re: Using Interrup for timing
You can use timer calculator to help you set up timer interrupts
https://www.mikroe.com/timer-calculator
1 second is not possible, so use 10 millisecond interrupt, count 100 interrupts and set a flag
My attempt at a solution is attached. It assumes 8 MHz 2-pin crystal used
Welcome to the forum
https://www.mikroe.com/timer-calculator
1 second is not possible, so use 10 millisecond interrupt, count 100 interrupts and set a flag
My attempt at a solution is attached. It assumes 8 MHz 2-pin crystal used
Welcome to the forum
- Attachments
-
- forum.zip
- (30.65 KiB) Downloaded 25 times
Start every day with a smile...... (get it over with)
Re: Using Interrup for timing
Thanks, this is exactly what I was looking for. How to confirm the timing using the debugging method?
Re: Using Interrup for timing
Thanks for the solution, its working perfectly as I needed. I couldn't perform simulation in the software simulator but tried it in proteus. Thanks once again.