View previous topic :: View next topic |
Author |
Message |
Guest
|
12f675 problem with INT_RA |
Posted: Tue Nov 13, 2007 3:38 pm |
|
|
OK, here is the problem:
I`m programing a 12f675, and I need to simulate an interrupt when the start bit is at the A3 pin, because the program is too busy excecuting a lot of rutines, so it cannot take the time enougth to check the pin A3 again, and again in order to detect the change, so I'm using the chage state interrupt for the A3 pin.
The problem is tha the compiler shows me an error
i tried this:
enable_interrupts(INT_RA3);
enable_interrupts(INT_RB); << is this needed
enable_interrupts(GLOBAL);
at the main
and this
#INT_RA3 <-- but it says that it doesn't work, that this is not a valid interrupt
void RA3_isr(){
}
please help!
thanks!
pd.: this interrupt is general, or identifies witch pin changes? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Guest
|
|
Posted: Tue Nov 13, 2007 5:31 pm |
|
|
ok.
the version is 3.180 (PCB)
then i just have to enable INT_R3 and use INT_RB.
does it work for pic12f675?
i hope! i'll try then!
thanks for asking! and if you have another suggest i'm lisening!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Nov 13, 2007 6:13 pm |
|
|
Quote: | I`m programming a 12f675.
the version is 3.180 (PCB) |
The 12F675 requires the PCM compiler. If it's compiling, then you have
PCM (not PCB). |
|
|
Guest
|
|
Posted: Wed Nov 14, 2007 2:15 pm |
|
|
PCM, yes, you are right. Sorry about the mistake, but I still with the question, when I enable the interrupt INT_RA3, do I have to enable INT_RB?
Also, that interrupt will execute when detect a change on other pins, or only when changes pin A3?
Thanks for any suggestions. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 14, 2007 3:13 pm |
|
|
Here's a demo program for INT_RA for your version of the compiler.
It has several "fixes" that are necessary for vs. 3.180.
This program toggles pin A2 in a while() loop in main. You have to
put a jumper between pins A2 and A3. Then pin A3 will receive the
square wave from pin A2. It will generate an interrupt on each edge
of the input square wave. The interrupt routine will then toggle pin A0
on every interrupt. So pin A0 will output a square wave at the same
frequency as the input on pin A3. You can look at it with an oscilloscope
and see this.
Code: |
#include <12F675.h>
#fuses INTRC_IO, NOWDT, NOMCLR, PUT, BROWNOUT
#use delay(clock=4000000)
#byte ADCON0 = 0x1F
#bit GPIF = 0x0b.0
#byte PortA = 5
// Need to use INT_RB with vs. 3.180 (instead of INT_RA)
#INT_RB
void int_ra_isr(void)
{
char c;
output_toggle(PIN_A0);
c = PortA; // Clear mismatch condition
}
//===========================
void main()
{
int8 c;
setup_comparator(NC_NC);
ADCON0 = 0; // Turn off ADC -- Needed for vs. 3.180
output_low(PIN_A0);
output_low(PIN_A2);
c = PortA; // Clear mismatch condition
GPIF = 0; // Clear INT_RA interrupt
enable_interrupts(INT_RA3);
enable_interrupts(GLOBAL);
while(1)
{
output_high(PIN_A2);
delay_ms(50);
output_low(PIN_A2);
delay_ms(50);
}
}
|
|
|
|
Guest
|
|
Posted: Wed Nov 14, 2007 6:39 pm |
|
|
I'll try with this then!
Thank you! |
|
|
Guest
|
|
Posted: Sun Nov 18, 2007 10:50 am |
|
|
Thank you a lot!
It works! |
|
|
|