Salut,
je voudrais que quelq'un m'explique la différence entre ces deux compilateurs au niveau des outils prévus pour la gestion d'interuptions,
avec High-tech, il est possible d'utiliser des registres et bits prévus pour la gestion précises des interruptions ( INTF,OPTION,PEIE,GIE,INTE,..., ) alors qu'avec le compilateur CCS il me semble qu'il n'y a que des fonctions prédéfinies , remplissent-t-ils les mêmes rôles ??
voici un lien vers un code d'interruption sur INT/RB0 avec High-Tech PIC C:
http://www.electroniciens.aquitaine-...MG/c/int_rb0.c
voici un petit code que j'ai testé (CCS), qui consiste à inverser l'état d'une LED à chaque interruption sur RB0 pour un PIC16F876 (ne marche pas à tout les appuis )
Code:/* #INT_EXT //interruption sur RB0 void ext_isr() //fonction de l'interruption { boolean button_pressed; button_pressed=!button_pressed; // à chaque fois on inverse l'état de la variable if(button_pressed) output_high(pin_a0); //allmer la LED else output_low(pin_a0); //éteindre la LED delay_ms(300); // debounce button (temps d'anti-rebond) } void main() { port_b_pullups(TRUE); setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_spi(FALSE); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); ext_int_edge(H_TO_L); enable_interrupts(INT_EXT);// activer l'interruption sur RB0 enable_interrupts(GLOBAL); set_tris_b(0xff); //portb en entree set_tris_a(0); // porta en sortie while(true);
voici ce que l'aide du CCS dit à propos des interruptions:
Code:Interrupts -------------------------------------------------------------------------------- The following functions allow for the control of the interrupt subsystem of the microcontroller. With these functions, interrupts can be enable, disabled, and cleared. With the preprocessor directives, a default function can be called for any interrupt that does not have an associated isr, and a global function can replace the compiler generated interrupt dispatcher. 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 trigger. This can be either rising or falling edge. clear_interrupt() This function will the specified interrupt flag. This can be used if a global isr is used, or to prevent an interrupt from being serviced. Relevant Preprocessor: #device high_ints= This directive tells the compiler to generate code for high priority interrupts. #int_xxx fast This directive tells the compiler that the specified interrupt should be treated as a high priority interrupt. Relevant Interrupts: #int_default This directive specifies that the following function should be called if an interrupt is triggered but no routine is associated with that interrupt. #int_global This directive specifies that the following function should be called whenever an interrupt is triggered. This function will replace the compiler generated interrupt dispatcher. #int_xxx This directive specifies that the following function should be called whenever the xxx interrupt is triggered. If the compiler generated interrupt dispatcher is used, the compiler will take care of clearing the interrupt flag bits. Relevant Include Files: none, all functions built in. Relevant getenv() Parameters: none Example Code: #int_timer0 void timer0interrupt() // #int_timer associates the following function with the // interrupt service routine that should be called enable_interrupts(TIMER0); // enables the timer0 interrupt disable_interrtups(TIMER0); // disables the timer0 interrupt clear_interrupt(TIMER0); // clears the timer0 interrupt flag
je vous remercie d'avance pour vos réponses.
-----