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);
}
}
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(;
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);
}
}