Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Method 1: Polling
- main()
- {
- uint8_t count = 0;
- ..
- ..
- while(posedge_input) {
- count++;
- if(count == 0) {
- // Start timer
- }
- else if(count == 7) {
- // Stop, Read and Reset timer value
- count = 0;
- }
- }
- ..
- ..
- }
- // Method 2: Hardware Interrupt
- // You'll have to read the datasheet for this, I don't have any tutorial for this yet.
- uint8_t count = 0; // Global counter
- Hardware_Interrupt_ISR()
- {
- if(posedge_input) {
- count++;
- if(count == 0) {
- // Start timer
- }
- else if(count == 7) {
- // Stop, Read and Reset timer value
- count = 0;
- }
- }
- }
- main()
- {
- ..
- ..
- // Do general initialization
- ..
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement