Pic interrupt

Thread Starter

srpott40

Joined Feb 27, 2013
4
I am currently writing the program for a PIC16F84A, and i have got stuck on how to program a interrupt. I would like the PIC to be interrupted when PortA 4 is high (input 4), and then place all of PortB high (output ports),

Hope somebody is able to help
 

tshuck

Joined Oct 18, 2012
3,527
I am currently writing the program for a PIC16F84A, and i have got stuck on how to program a interrupt. I would like the PIC to be interrupted when PortA 4 is high (input 4), and then place all of PortB high (output ports),

Hope somebody is able to help
There is no interrupt capability on that pin. As a work around(since this can be the clock source for TMR0), you can preload TMR0 with 0xFF and us the input as the clock for TMR0(positive edge-triggered), each time the pin goes HI, the timer will overflow , generating an interrupt, but you'd need to load TMR0 with 0xFF each time.

To be any more specific than that, we need to know what compiler you are using...
 

t06afre

Joined May 11, 2009
5,936
RA4 is not an Interrupt-on-change pin. RA4 can be selected to be the clock input to the TMR0 timer/counter. It may be that you can use that in some way. Pre loading TMR0 with 0xff. And then let a rising edge on this pin causing an overflow that trigger an interrupt. This is from the top of head. But you can look into it
 

Thread Starter

srpott40

Joined Feb 27, 2013
4
Well i suppose it does not have to be that pin, as i could easily change the circuit diagram, which pin normally has the INTERRUPT stuff on? And i am writing the code on notepad++ then transferring it to MPLab which it then transferring it to the chip
 

tshuck

Joined Oct 18, 2012
3,527
Well i suppose it does not have to be that pin, as i could easily change the circuit diagram, which pin normally has the INTERRUPT stuff on
If you'll look at the datasheet, page 3 shows RB0 as having external interrupt capabilities[INT], PORTB also typically has an interrupt-on-change,, but this will be generated for any pin in PORTB changing.
 

tshuck

Joined Oct 18, 2012
3,527
How can that be done?
...something like this will do it...
uses PORTA<0:3> as the low nibble and PORTB<4:7> as the upper nibble
Rich (BB code):
unsigned char data;
...
PORTB &= 0x0F; //clear upper nibble
PORTA &= 0xF0;//clear lower nibble
PORTB |= (data & 0xF0); //write upper nibble
PORTA |= (data & 0x0F); //write lower nibble
 
Top