Hi,
I'm trying to make int_ext work on Embedded Ethernet Kit. I try to turn on a LED placed in PIN A5 when I push the button in Pin A4 but it never gets into the interruption routine. Pin a4 is connected to RB0 to treat the interruption.
The PIC is 18F4620 and clock =40MHz.
I can`t see anything wrong with the code
Code:
int tone = 0; //activated tone 1 or deactivated 0
int ctl = 0; // control flag
#int_EXT
void EXT_isr(void)
{
if (tone == 0){
ctl = 1;
output_toggle(GREEN_LED);
}else{
output_toggle(GREEN_LED);
tone = 0 ;
}
delay_ms(DELAY); //200ms
}
void main()
{
ext_int_edge(H_TO_L);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
//Example blinking LED program
while(true){
if (ctl == 1){
// puts("Envio tonos");
ctl = 0;
tone = 1;
}
}
}
I tried it using EXT1 but still having the same problem.
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Fri Feb 07, 2014 1:52 pm
Look at the schematic. Pins B0 and B1 are used for external circuits.
They are driven by 74HCT08 drivers. You can't use those pins.
Check the schematic carefully to see if pin B2 is free. I didn't check it.
For the future, the most important things to check if a pin doesn't work are:
1. External circuit connections that already exist on your board.
2. Multiple configurations in the PIC for that pin for different peripherals.
Make sure the pin isn't enabled for the UART, CCP pwm, etc.
3. Limitations of the pin. Some pins are "input only". The can't do output.
4. Your TRIS settings in your code may have disabled the pin as an
input. The pins default to be an input.
5. Requirements for a pullup resistor for the pin to be able to switch high
and low as an output pin. This mostly is for older PICs such as 16F877
on pin A4.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum