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.

Trying to output interrupt help

Status
Not open for further replies.

DMW

New Member
Hello

I am simply trying to have 4 buttons going into my PIC12F675, and when a user pushes one i wish my code to carry on, but i am experiencing many errors which im sure shouldn't be there.

With this simple test program:

Code:
#include<pic.h>
__CONFIG(0x3FE4);

unsigned char carry = 0 ;

void main(){

//Comparator = 0ff
CMCON=0x07;
//Set prescaler to WDT Timer0 = 1:1 Instruction Cycle
OPTION = 0x08;
//Set prescaler on Timer1
T1CON = 0x30;  //1:8 prescaler, tmr1 disabled
//PortSetup:
GPIO = 0x00;
//Tristate Output:
TRISIO =0x1F; //All but GPIO5 are inputs
//ALL Digital IP/OP
ANSEL=0x00;
//WeakPullups:
WPU=0x17;  //all but GPIO5
//Timer1
TMR1L=0x00;
TMR1H=0x00;
//GPIO Interrupts all but GPIO5
IOCB=0x1F;
//Timer0 & GPIO Interrupt:
INTCON = 0x88;  //disable tmr0 interrupt as will pull out of sleep mode

while(carry!=1);
INTCON=0x00;

GPIO5=1;
while(1);
}

//Interrupt Function:
void interrupt tc_int (void){
GPIF=0;
carry = 1;
}

Simply my LED on GPIO5 should light, but however it does not!, it flashes quickly [just visible] and stops, even though ive temporary disabled the interrupt even though it shouldn't make a difference?.

If i remove the interrupt completely from the code then it works fine, also i noticed that often having weak pullups seems to sometimes stop my GPIO5 from outputting even tho ive set it as an output and disabled WPU on that pin.

Can anyone explain whats happening or advise a way i can diagnose the problem further?

Thanks
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top