C:
#include<htc.h>
#define _xtal_freq 4000000
__config(0x31c4);
#define green 0b00000110
void interrupt isr(void)
{
if (gpif)
{
if(gpio3==0)
gpio=0b001111111;
}
gpif=0;
}
void main(void)
{
ansel = 0b00000000;
option_reg = 0b11010001;
cmcon = 0b00000000;
trisio= 0b00001000;
gie = 1;
//t0ie = 1;
t0if = 0;
gpif=0;
iocb=gpio3;
//gpio=0b00000100;
__delay_ms(5);
__delay_us(50);
__delay_ms(200);
gpio |= (1<<5);
gpio &= ~(1<<7);
gpio=green;
while(1)
{}
}
works fine.... Sorry there is one underscore before xtal... You forgot the config....
Htc.h calls pic.h so there is no need to include it...
The interrupt isn't working because its not switched on.. When swithed on it fires every 32μs... Is that what you wanted???