Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Portb_interrupt+ccs compiler

Status
Not open for further replies.

manikandanshine

Full Member level 1
Joined
Aug 15, 2012
Messages
99
Helped
7
Reputation
14
Reaction score
7
Trophy points
1,298
Location
india
Activity points
1,809
Portb interrupt works onr time only.....after that i clear that interrupt flag.......but it does not work.....
Can anyone help me?
 

Portb interrupt works onr time only.....after that i clear that interrupt flag.......but it does not work

You must first read PORTB to clear the mismatch condition then clear the interrupt flag.
 

Ensure that you informed the processor about the Intterrupt flag is cleared.
For example
void interrupt()
{
VICVectAddrr=0;
}

You will it will generate the interrupt for every time.
 

Portb interrupt works onr time only.....after that i clear that interrupt flag.......but it does not work.....
Can anyone help me?

Hello manikandanshine, for clarity which micro are you using, and can you upload the portion of code that has the problem?

Greetings!
 

There are a couple of things to check here:

1- As 'zuisti' said Portb should be read before enabling the interrupt again, check if the flag keeps getting set or not, if it's getting set then you're not reading Portb,
2- The interrupt might be getting disabled somehow, or the 'GIE' bit,
3- Rest of the code runs as intended or not.
 

Hello guys, everything you say is true, but if we are talking about programming with the CCS compiler, as says the title of the thread, this compiler is internally responsible of doing all of that. That is why it would be good to see the code manikandanshine is using, as well as the PIC he is using.

Greetings!
 

#include <16f876.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP,BROWNOUT,PUT
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
/////////////////////////////Working Vars//////////////////////////////////////
int16 counter=0;
int1 ina=0,inb=0,PLast=0;
/////////////////////////////////////////
#INT_RB
void rb_isr(void){

ina=input(pin_b4);
inb=input(pin_b5);
///////////////////////////////////////////
if((PLast==0)&&(ina==1)){
if(inb==0){counter--;}
else {counter++;}
}
PLast = ina;
printf("Encoder = %05Ld \r",counter);
}
////////////////////////////////////////////////////////////////////////////////
void main(void) {

set_tris_a (0b00000001);
set_tris_b (0b11110001);
set_tris_c (0b10000001);
setup_adc_ports(NO_ANALOGS);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
printf("\rRotary Encoder Test\r");
delay_ms(500);
///////////////////////////////////////////
while (true){

}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top