I've been working on little projects to learn the C language using MPLAB IDE and High-Tech C lite compiler.
I have noticed that although my codes function as they're supposed to, my timing is always off and I'm not sure why. A flash of the LED for 1 second is coming out to be about 800mS or so, and I'm unsure as to the discrepancy.
I have heard that the High-Tech C compiler Lite version does not allow for precise timing operations, though I'm not sure if that's actually the case, but if anyone has heard this and it turns out it's not a problem with my code, that'd be nice to know. Here is my code snippet where I define clocks:
Also, I'm calling delays using this routine:
Thanks for the help.
I have noticed that although my codes function as they're supposed to, my timing is always off and I'm not sure why. A flash of the LED for 1 second is coming out to be about 800mS or so, and I'm unsure as to the discrepancy.
I have heard that the High-Tech C compiler Lite version does not allow for precise timing operations, though I'm not sure if that's actually the case, but if anyone has heard this and it turns out it's not a problem with my code, that'd be nice to know. Here is my code snippet where I define clocks:
Rich (BB code):
// CONFIGURATION
#include <htc.h>
#define _XTAL_FREQ 4000000
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & BORDIS & LVPDIS & UNPROTECT & UNPROTECT);
/*************************************************/
// GLOBAL VARIABLES
unsigned char dlycnt; //DELAY COUNTER
unsigned char fpnum; //FLASH PATTERN NUMBER
unsigned char set = 0;
unsigned char dbnce; //SWITCH DEBOUNCE
/*************************************************/
void main() //MAIN PROGRAM START
{
unsigned char address = 0; //DEFINE ADDRESS FOR EEPROM
INTEDG = 1; //TRIGGER INTERRUPT ON RISING EDGE
INTE = 1; //RB0 EDGE INTERRUPT ENABLED
ei(); //GLOBAL INTERRUPTS ENABLED
fpnum = eeprom_read(address); //DATA READ FROM EEPROM AND COPIED TO fpnum
OSCF=1; // INTERNAL OSCILLATOR 48KHz
TRISA=0XFF; // TRISA NOT USED, ALL SET AS INPUT
TRISB=0XF7; // TRISB 7-4 INPUT, 3 OUTPUT, 2-0 INPUT
Rich (BB code):
RB3=1; //SET RB3 HIGH
for (dlycnt=0; dlycnt<10; dlycnt++) //CALL 1 SECOND DELAY
{
__delay_ms(100);
}