Professional Documents
Culture Documents
Author Message
I'm trying to read one of my robot sensors as an interrupt, it works as a software loop but the
interrupt is backwards.
Condition: The robot is on a black surface PIN_RB0 HIGH, will turn low on a white surface.
This works:
Code:
if( !INPUT(LINE_L_DET2) ) {
printf("\n\rLine Left Detect");
}
I tried to turn the above loop into an interrupt but I only get the interrupt when: Robot enters
the white surface, Robot goes back to black surface = INTERRUPT
I tried switching ext_int_edge(INT_EXT,H_TO_L); but it will not change the outcome. I need the
interrupt when the robot goes from black onto the white surface not the other way around.
#include <18F2620.h>
#device adc=10
1 от 3 27.2.2007 г. 09:37
CCS :: View topic - Interrupt ext_int_edge triggers backwards http://ccsinfo.com/forum/viewtopic.php?t=29493&highlight=int0...
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy
mode)
#FUSES NOPBADEN //PORTB pins are configured as analog input channels on RESET
#FUSES NOLPT1OSC //Timer1 configured for low-power operation
#FUSES NOMCLR //Master Clear pin enabled
#use delay(clock=8000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PC)
#use fast_io(b)
#use fast_io(c)
#int_ext
void rb0__isr() {
disable_interrupts(INT_EXT);
printf("\r\n\r\nInterrupt\r\n");
}
void main()
{
setup_oscillator(OSC_8MHZ);
set_tris_a(0b00000001 );
set_tris_b(0b00001111 );
set_tris_c(0b00000000 );
setup_adc(ADC_OFF);
setup_spi(FALSE);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//Turn Off All IR Emitters
output_low(LINE_L_EM);
//All IR Emitters Off
ext_int_edge(INT_EXT,H_TO_L); // interrupt when robot enters the white border around the arena
enable_interrupts(global); //Enable Interrupts
enable_interrupts(INT_EXT); //Enable Interrupt in INT0
do {
output_high(LINE_L_DET); //Turn on Power to IR Detectors
output_high(LINE_L_EM); //Turn on Power to IR Emitters (they are always on to use interrupts)
enable_interrupts(INT_EXT);
} while (TRUE);
}
Quote:
Joined: 06 Sep 2003
Posts: 6760 ext_int_edge(INT_EXT, H_TO_L);
Code:
ext_int_edge(0,H_TO_L);
Page 1 of 1
2 от 3 27.2.2007 г. 09:37
CCS :: View topic - Interrupt ext_int_edge triggers backwards http://ccsinfo.com/forum/viewtopic.php?t=29493&highlight=int0...
3 от 3 27.2.2007 г. 09:37