PDA

View Full Version : Doubt with interrupt on change



lugo.p
- 4th March 2010, 23:55
Well my problem is that i want to make an interrupt on change with RA0 on PIC16F684 but since i'm beginer in this and i'm not a well english reader i have troubles doing this, mi code next:

[B]inicio:
if INTCON.0 = 0 THEN disparo
GOTO inicio

disparo:
PORTA.0 = 1
INTCON.0 = 0
FREQOUT PORTC.5,10,38000
PORTC.5 = 0
RONDAS = RONDAS - 1
GOTO inicio[\B]

if somebody can help me, i'd be very glad. Thanks

Archangel
- 5th March 2010, 04:29
Hi lugo.p,
Let's start off with, change the big old Capital B to the word code, then your code tag will work, do it on both ends.

Add this to your code along with the proper configs and define your OSC.




ON INTERRUPT GoTo disparo
INTCON = %10001001
'Bit 0 = RAIF Port A Interrupt Flag
'Bit 1 = INTF INT Flag
'Bit 2 = T0IF Timer zero Interrupt Flag
'Bit 3 = RAIE Port A Interrupt ENABLE
'Bit 4 = INTE INT Enable
'Bit 5 = T0IE Timer zero Interrupt Enable
'Bit 6 = PEIE Peripheral Interrupt Enable
'Bit 7 = GIE Global Interrupt Enable

IOCA = %00000001 ' enable IOC on RA0
'Bit 0 = RA0 interrupt on change
'Bit 1 = RA1 " " " " "
'Bit 2 = RA2 " " " " "
'Bit 3 = RA3 " " " " "
'Bit 4 = RA4 " " " " "
'Bit 5 = RA5 " " " " "
'Bit 6 = Unimplemented
'Bit 7 = Unimplemented

OPTION_REG = %00000000
'Bit 0 = PS Prescaler
'Bit 1 = PS Prescaler
'Bit 2 = PS Prescaler
'Bit 3 = PSA Prescaler Assignment bit
'Bit 4 = T0SE Timer zero source edge select bit
'Bit 5 = T0CS Timer zero clock source select bit
'Bit 6 = INTEDG Interrupt Edge Select bit
'Bit 7 = RAPU PortA weak pullup bit

lugo.p
- 5th March 2010, 15:22
And puting that on my code IOC will work?

Because i have configured IOCA = $01, OPTION_REG = $00 and INTCON = $98