It is currently 20 Oct 2018 05:56

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 16 Oct 2017 23:48 
Offline

Joined: 16 Oct 2017 23:19
Posts: 2
Hello
I am new in this area, so I would be very grateful if you help me.
I am learning about microcontrollers. I started with PIC12F675.

My problem is next:
I want to take the input (which is digital) and it can be HIGH (1) or LOW (0) and I want to measure the time from one change to another (example: first come High (1), now I start to count the time and when the next input value becomes Low (0) I will stop counting, reset the timer and start counting until it become again High(1) and so on).
It will be great if you can tell me how could I do the measure in milliseconds.

I know how to do my initialize on registers
void init()
{
     ANSEL = 0;                 // All I/O pins are configured as digital
     TRISIO = 0;                // All GP pins are configured as output
     TRISIO.B3 = 1;             // PIN GP3 is configured as input
     GPIO = 0;                  // Clear GPIO
     CMCON = 7;                 // Turn off the comparators
}

but the rest of the program is kind of unknown to me.


Top
 Profile  
 
PostPosted: 17 Oct 2017 18:03 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1717
Hi,

Welcome to the MikroE forum.

You can try to use for example interrupt-on-change, and have the interrupt-handler code start a timer
on the rising edge and stop the timer on the falling edge.

You may find this thread useful:

viewtopic.php?f=88&t=33775#p153392

Kind regards,
Lana


Top
 Profile  
 
PostPosted: 19 Oct 2017 17:51 
Offline

Joined: 16 Oct 2017 23:19
Posts: 2
Thank you so much for the explanation and the link, I will look at it. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: