#include <htc.h>
#include <pic.h>
__CONFIG(XT & WDTDIS & PWRTEN & BORDIS & LVPDIS & DUNPROT & WRTEN & DEBUGDIS & UNPROTECT );
#define _XTAL_FREQ 4000000
#define TMR0_TICK 250
#define TMR0_PRESCALE 1 //(FOSC=16MHz,Prescale=3),(FOSC=4MHz,Prescale=1)
#define TMR0_RELOAD (255 - (TMR0_TICK-6))
void TMR0Init(void);
int count=1000;
void main (void)
{
TMR0Init();
TRISB=0x00;
ADCON1=0x06;
TRISA=0x00;
PORTA=0xff;
PORTA=0x00;
PORTA=0xff;
// PORTA=0x00;
while(1)
{
;
}
}
void TMR0Init()
{
TMR0 = 0; // Clear TMR0
INTCON = 0; // Disable all interrupts and clear T0IF
OPTION &= 0xC0; // Turn off least 6 bits to configure tmr0
OPTION |= TMR0_PRESCALE; // set prescaler to 1
TMR0=1;
T0IE = 1; // Enable TMR0 interrupt
GIE = 1; // Enable the global interrupt
}
void interrupt tmr0_isr(void)
{
if(TMR0IF)
{
TMR0 = TMR0_RELOAD;
count++;
if(count == 1000)
{
PORTB=~PORTB; //Toggles LED once per second
count = 0;
}
T0IF = 0;
}
}
Build C:\Users\marco\Downloads\Proyectos\GLC\16f877\ohyeah for device 16F877
Using driver C:\Program Files (x86)\HI-TECH Software\PICC\lite\9.60\bin\picc.exe
Make: The target "C:\Users\marco\Downloads\Proyectos\GLC\16f877\main.obj" is out of date.
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\lite\9.60\bin\picc.exe" -C C:\Users\marco\Downloads\Proyectos\GLC\16f877\main.c -q --chip=16F877 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Executing: "C:\Program Files (x86)\HI-TECH Software\PICC\lite\9.60\bin\picc.exe" -oohyeah.cof -mohyeah.map --summary=default --output=default main.obj --chip=16F877 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH PICC-Lite COMPILER (Microchip PICmicro) V9.60
Copyright (C) 1984-2006 HI-TECH SOFTWARE
Memory Usage Map:
Program space:
CODE used 4Dh ( 77) of 800h words ( 3.8%)
CONST used 0h ( 0) of 800h words ( 0.0%)
ENTRY used 16h ( 22) of 800h words ( 1.1%)
STRING used 0h ( 0) of 800h words ( 0.0%)
Data space:
BANK0 used 6h ( 6) of 60h bytes ( 6.3%)
BANK1 used 0h ( 0) of 50h bytes ( 0.0%)
COMBANK used 1h ( 1) of 10h bytes ( 6.3%)
EEPROM space:
EEDATA used 0h ( 0) of 100h bytes ( 0.0%)
ID Location space:
IDLOC used 0h ( 0) of 4h bytes ( 0.0%)
Configuration bits:
CONFIG used 1h ( 1) of 1h word (100.0%)
Summary:
Program space used 63h ( 99) of 800h words ( 4.8%)
Data space used 7h ( 7) of B0h bytes ( 4.0%)
EEPROM space used 0h ( 0) of 100h bytes ( 0.0%)
ID Location space used 0h ( 0) of 4h bytes ( 0.0%)
Configuration bits used 1h ( 1) of 1h word (100.0%)
Loaded C:\Users\marco\Downloads\Proyectos\GLC\16f877\ohyeah.cof.
********** Build successful! **********