Ext_int_edge is a function that checks the interrupt flag of the specified interrupt. Enable_interrupts clears the specified interrupt flag. #int_default is called if an interrupt is triggered but no routine is associated with it.
Ext_int_edge is a function that checks the interrupt flag of the specified interrupt. Enable_interrupts clears the specified interrupt flag. #int_default is called if an interrupt is triggered but no routine is associated with it.
Ext_int_edge is a function that checks the interrupt flag of the specified interrupt. Enable_interrupts clears the specified interrupt flag. #int_default is called if an interrupt is triggered but no routine is associated with it.
// ----------- Seleccion del flanco de interrupcion
// ext_int_edge (source, edge) // source is a constant 0,1 or 2 for the PIC18XXX and 0 otherwise. Source is opt ional and defaults to 0. // edge is a constant H_TO_L or L_TO_H representing "high to low" and "low to hi gh" // specify the rising or falling edge. ext_int_edge( 2, L_TO_H); // Set up PIC18 EXT2 ext_int_edge( H_TO_L ); // Sets up EXT // ------------ Chequeo del estado de la interrupcio interrupt_active (interrupt) // Parameters: Interrupt constant specifying the interrupt // Returns: Boolean value // Function: The function checks the interrupt flag of the specified interrupt a nd returns true in case the flag is set. interrupt_active(INT_TIMER0); interrupt_active(INT_TIMER1); //**************************************************************************** Relevant Functions: disable_interrupts() Disables the specified interrupt. enable_interrupts() Enables the specified interrupt. ext_int_edge() Enables the edge on which the edge interrupt should trig ger. This can be either rising or falling edge. clear_interrupt() This function will clear the specified interrupt flag. T his can be used if a global isr is used, or to prevent an interrupt from being s erviced. Relevant Preprocessor: #DEVICE HIGH_INTS= This directive tells the compiler to generate code for h igh priority interrupts. #INT_XXX fast This directive tells the compiler that the specified int errupt should be treated as a high priority interrupt.
Relevant Interrupts: #int_default This directive specifies that the following function sho uld be called if an interrupt is triggered but no routine is associated with tha t interrupt. #int_global This directive specifies that the following function sho uld be called whenever an interrupt is triggered. This function will replace th e compiler generated interrupt dispatcher. #int_xxx This directive specifies that the following function sho uld be called whenever the xxx interrupt is triggered. If the compiler generated interrupt dispatcher is used, the compiler will take care of clearing the inter rupt flag bits. Example Code: #int_timer0 void timer0interrupt() // #int_timer associates the following function with the // interrupt service routine that should be call ed enable_interrupts(TIMER0); // enables the timer0 interrupt disable_interrtups(TIMER0); // disables the timer0 interrupt clear_interrupt(TIMER0); // clears the timer0 interrupt flag //****************************************************************************** delay_ms (time) Parameters: time - a variable 0-65535(int16) or a constant 0-65535 Function: This function will create code to perform a delay of the specified len gth. Time is specified in milliseconds. This function works by executing a prec ise number of instructions to cause the requested delay. It does not use any ti mers. If interrupts are enabled the time spent in an interrupt routine is not co unted toward the time. The delay time may be longer than requested if an interrupt is service d during the delay. The time spent in the ISR does not count toward the delay ti me Requires: #USE DELAY Examples: #use delay (clock=20000000) delay_ms( 2 ); void delay_seconds(int n) { for (;n!=0; n- -) delay_ms( 1000 ); }
Sintax: delay_cycles (count) Parameters: count - a constant 1-255 Function: Creates code to perform a delay of the specified number of instruction clocks (1-255). An instruction clock is equal to four oscillator clocks. Examples: delay_cycles( 1 ); // Same as a NOP delay_cycles(25); // At 20 mhz a 5us delay Sintax: delay_us (time) Parameters: time - a variable 0-65535(int16) or a constant 0-65535 Note: Previous compiler versions ignored the upper byte of an int16, now the u pper byte affects the time. do { output_high(PIN_B0); delay_us(duty); output_low(PIN_B0); delay_us(period-duty); } while(TRUE); //****************************************************************************** ****** // set timing config to 32KHz, User sets the fuses // elsewhere, restart watchdog timer // on delay_us() and delay_ms() #use delay (clock=32000, RESTART_WDT)
//the following 4 examples all configure the timing library //to use a 20Mhz clock, where the source is a crystal. #use delay (crystal=20000000) #use delay (xtal=20,000,000) #use delay(crystal=20Mhz) #use delay(clock=20M, crystal)
//application is using a 10Mhz oscillator, but using the 4x PLL //to upscale it to 40Mhz. Compiler will set config bits. #use delay(oscillator=10Mhz, clock=40Mhz)
//application will use the internal oscillator at 8MHz. //compiler will set config bits, and set the internal //oscillator to 8MHz. #use delay(internal=8Mhz)