Bonjour
Est ce que qlq un peut m'aider à comprendre ce que fait le programme suivant :
un programme en C pour le pic18f4620
Merci Bcp , j'attends vote réponse le plus tôt possible .Code:/** I N C L U D E S **************************************************/ #include "p18f4620.h" #include "delays.h" #include <stdio.h> #include <stdlib.h> #include <usart.h> /**Bits de configuration**********************************************/ #pragma config OSC=HSPLL #pragma config PWRT=ON #pragma config BOREN=OFF #pragma config WDT=OFF #pragma config MCLRE=ON #pragma config PBADEN=OFF #pragma config LVP=OFF #pragma config XINST=OFF #define CLOCK_FREQ (40000000) // Hz /*#pragma config OSC = INTIO7//Internal oscillator block, port function on RA6 and RA7 #pragma config FCMEN = OFF//Fail-Safe Clock Monitor disabled #pragma config PWRT = OFF//Power-up Timer disabled #pragma config WDT = OFF//Watchdog Timer disabled #pragma config MCLRE = ON//MCLR pin enabled; RE3 input pin disabled*/ /**Prototypes**********************************************************/ void InitInterrupt(); void InitUART(void); void Fonction (int fct); void UpdateDutyCycle(); void low_isr(); /**Variables***********************************************************/ unsigned int cnt8000 = 0; char cntDty = 0; char boolUpdateDty = 0; const unsigned char Dty [24] = {128, 160, 191, 218, 238, 251, 255, 251, 238, 218, 191, 160, 128, 95, 64, 37, 17, 4, 0, 4, 17, 37, 64, 95}; // Testing unsigned long int tempDty1 = 0, tempDty2 = 0; /*SETUP ISR VECTOR******************************************************/ #pragma code low_vector=0x18 //setup the ISR vector void low_interrupt (){ _asm GOTO low_isr _endasm //jump to interrupt handler } #pragma code /*ISR********************************************************************/ #pragma interruptlow low_isr //the ISR void low_isr() { if (PIR1bits.TMR2IF == 1) { PIR1bits.TMR2IF=0; boolUpdateDty = 1; if (cnt8000 < 8000) cnt8000++; else cnt8000 = 0; } } #pragma code /** D E C L A R A T I O N S *******************************************/ void main() { InitInterrupt(); T2CONbits.TMR2ON = 1; while (1) { if (boolUpdateDty==1) { boolUpdateDty = 0; UpdateDutyCycle(); } } } void InitInterrupt() { PIE1bits.TMR2IE = 1; //enable Timer2 interrupt INTCONbits.PEIE = 1; //enable peripheral interrupts INTCONbits.GIE = 1; //enable glogal interrupts IPR1bits.TMR2IP = 0; // low priority } void UpdateDutyCycle() { if ((cnt8000%334)==0) { tempDty1 = 50000/255; tempDty2 = Dty[cntDty]*tempDty1/100; SetDCPWM1(tempDty2); if (cntDty < 22) cntDty++; else cntDty = 0; } }
-----