Ccs _ View Topic - Interrupt Ext_int_edge Triggers Backwards

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ccs _ View Topic - Interrupt Ext_int_edge Triggers Backwards as PDF for free.

More details

  • Words: 661
  • Pages: 3
CCS :: View topic - Interrupt ext_int_edge triggers backwards

FAQ

Forum Help Profile

Official CCS Support

http://ccsinfo.com/forum/viewtopic.php?t=29493&highlight=int0...

Search

Log in to check your private messages

Register Log in

Interrupt ext_int_edge triggers backwards CCS Forum Index -> General CCS C Discussion View previous topic :: View next topic Author Jacky Guest

Message Interrupt ext_int_edge triggers backwards Posted: Mon Jan 15, 2007 3:40 pm

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. Example Program, the Sensor is connected to RB0(INT_EXT): Code: #include <18F2620.h> #device adc=10 #FUSES NOWDT //No Watch Dog Timer //#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale #FUSES INTRC_IO //Internal RC Osc, no CLKOUT //#FUSES HS //External HighSpeed Clock #FUSES NOPROTECT //Code not protected from reading #FUSES IESO //Internal External Switch Over mode enabled #FUSES NOBROWNOUT //No brownout reset //#FUSES BORV21 //Brownout reset at 2.1V #FUSES NOPUT //No Power Up Timer #FUSES NOCPD //No EE protection #FUSES NOSTVREN //Stack full/underflow will cause reset #FUSES NODEBUG //No Debug mode for ICD #FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18) #FUSES NOWRT //Program memory not write protected #FUSES NOWRTD //Data EEPROM not write protected #FUSES NOEBTR //Memory not protected from table reads #FUSES NOCPB //No Boot Block code protection #FUSES NOEBTRB //Boot block not protected from table reads #FUSES NOWRTC //configuration not registers write protected #FUSES NOWRTB //Boot block not write protected #FUSES FCMEN //Fail-safe clock monitor enabled

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) //Left Side of Sensor Array #define LINE_L_DET1 PIN_B2 //IR Detector on Inside #define LINE_L_DET2 PIN_B0 //IR Detector on Outside #define LINE_L_EM PIN_B5 //Power for IR Emitter #define LINE_L_DET PIN_B4 //Power On For IR Detector #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); } PCM programmer

Joined: 06 Sep 2003 Posts: 6760

Posted: Mon Jan 15, 2007 4:04 pm

Quote: ext_int_edge(INT_EXT, H_TO_L);

The first parameter is incorrect. See the manual. http://www.ccsinfo.com/downloads.php

Jacky Guest

Posted: Mon Jan 15, 2007 6:08 pm

thanks, changed to: Code: ext_int_edge(0,H_TO_L);

and all works well now. Thanks Display posts from previous: All Posts

Oldest First

CCS Forum Index -> General CCS C Discussion

Go All times are GMT - 6 Hours

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...

Jump to: General CCS C Discussion You can post new topics You can reply to topics You cannot edit your posts You cannot delete your posts You cannot vote in polls

Go in in in in in

this this this this this

forum forum forum forum forum

Powered by phpBB © 2001, 2005 phpBB Group

3 от 3

27.2.2007 г. 09:37

Related Documents