Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC12F675 Timer

Status
Not open for further replies.

wuchy143

Member
Hi All,

I"m trying to use a timer on the PIC12F675(I"m a noob trying to learn how to effectively use them to measure time) I"ve been able to get it so my TMRO is counting but I can't figure out what it's counting to. I simulate it in MPLAB IDE and with a 4MHZ clock I"m getting 1uS per instruction which doesn't make sense to me. Anyone can help??? Here is my code.


#include <htc.h>



__CONFIG(MCLREN & UNPROTECT & WDTDIS & INTIO);

void main()
{

//TMR0 = 0;
for(;;) { //Keep it on forever


CMCON = 0x07; // Digital I/O
ANSEL = 0; // Digital I/O
TRISIO = 0x00000000; // Set Pin I/O
STATUS = 0x00;
OPTION = 0; //Enableing TMR0


TMR0 = 0;

GPIO = 1;
GPIO1 = 1;
GPIO2 = 1;
GPIO4 = 1;
GPIO5 = 1;

//_delay(500000);
//_delay(500000);

GPIO = 0;
GPIO1 = 0;
GPIO2 = 0;
GPIO4 = 0;
GPIO5 = 0;

// _delay(500000);
//_delay(250);
}

}
 
hi,
The PIC divides the 4mHz clock by 4 for internal use, so its 1uSec...:)
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top