CCS - View Topic - INT0 Interrupt 18F242
CCS - View Topic - INT0 Interrupt 18F242
CCS - View Topic - INT0 Interrupt 18F242
Author Message
#include <18F242.H>
#fuses HS,NOWDT, NOPROTECT, PUT
#use DELAY (clock=20000000)
#use fast_io(A)
#use fast_io(B)
//int i;
//int x;
//int c;
#int_ext
void EXT_ISR()
{
output_high(PIN_A0);
delay_ms(200);
delay_ms(200);
delay_ms(200);
delay_ms(200);
delay_ms(200);
delay_ms(200);
output_high(PIN_A0);
}
/* main() */
void main()
{
1 от 3 01.3.2007 г. 11:24
CCS :: View topic - INT0 interrupt 18F242 http://ccsinfo.com/forum/viewtopic.php?t=25558&highlight=inte...
ext_int_edge(H_TO_L);
enable_interrupts(global);
enable_interrupts(int_rb);
while(1)
{
output_high(PIN_A3);
}
}
Greets,
Blob
_________________
IMEC rulez
Code:
Joined: 18 Mar 2004
Posts: 1334 /* Allow pin B0 to be an external interrupt pin */
Location: The Netherlands SET_TRIS_B(0b00010000);
You are configuring B4 as an input but your comment says B0.
Code:
#int_ext
void EXT_ISR()
{
output_high(PIN_A0);
delay_ms(200);
delay_ms(200);
delay_ms(200);
delay_ms(200);
delay_ms(200);
delay_ms(200);
output_high(PIN_A0);
}
Quote:
Joined: 08 Sep 2003
Posts: 813
Location: Buenos Aires la At the moment i'm trying to generate an external interrupt on the PIC 18F242.
Reina del Plata i want to generate the interrupt on pin RB0.
but it seems the interrupt is not catched...
enable_interrupts(int_rb);
Should be
enable_interrupts(INT_EXT);
I assume you have a pull-up resistor wired from +5V to PIN RB0 or:
port_b_pullups(TRUE); declared in your code.
To 'see' the RB0 interrupt action, the following code should be enough.
(If your compiler version has the output_toggle() function.)
2 от 3 01.3.2007 г. 11:24
CCS :: View topic - INT0 interrupt 18F242 http://ccsinfo.com/forum/viewtopic.php?t=25558&highlight=inte...
Code:
#int_ext
void EXT_ISR()
{
output_toggle(PIN_A0);
}
or if it doesn't:
Code:
int8 ext_trigger;
#int_ext
void EXT_ISR()
{
output_high(PIN_A0);
ext_trigger = TRUE;
}
void main()
{
while(1)
{
.......
your stuff
.......
if(ext_trigger)
{
delay_ms(200);
output_low(PIN_A0);
delay_ms(200);
ext_trigger = FALSE;
}
}
}
Best wishes,
Humberto
Page 1 of 1
3 от 3 01.3.2007 г. 11:24