diff --git a/Drivers/Src/TIMER.c b/Drivers/Src/TIMER.c index 7c68ef5..b098169 100644 --- a/Drivers/Src/TIMER.c +++ b/Drivers/Src/TIMER.c @@ -34,29 +34,33 @@ void MyPWM_init ( TIM_TypeDef * Timer,char Channel) if(Channel==1) { Timer->CCMR1&=~0x00FF; - Timer->CCMR1|=0x11<<5; - Timer->CCMR1&=~0x000F; + Timer->CCMR1 &= ~TIM_CCMR1_OC1M_0; + Timer->CCMR1 |= TIM_CCMR1_OC1M_1| TIM_CCMR1_OC1M_2; + Timer->CCER |= TIM_CCER_CC1E; } if(Channel==2) { Timer->CCMR1&=~0xFF00; - Timer->CCMR1|=0x11<<12; - Timer->CCMR1&=~0x0F00; + Timer->CCMR1 &= ~TIM_CCMR1_OC2M_0; + Timer->CCMR1 |= TIM_CCMR1_OC2M_1| TIM_CCMR1_OC2M_2; + Timer->CCER |= TIM_CCER_CC2E; } if(Channel==3) { Timer->CCMR2&=~0x00FF; - Timer->CCMR2|=0x11<<5; - Timer->CCMR2&=~0x000F; + Timer->CCMR2 &= ~TIM_CCMR2_OC3M_0; + Timer->CCMR2 |= TIM_CCMR2_OC3M_1| TIM_CCMR2_OC3M_2; + Timer->CCER |= TIM_CCER_CC3E; } if(Channel==4) { Timer->CCMR2&=~0xFF00; - Timer->CCMR2|=0x11<<12; - Timer->CCMR2&=~0x0F00; + Timer->CCMR2 &= ~TIM_CCMR2_OC4M_0; + Timer->CCMR2 |= TIM_CCMR2_OC4M_1| TIM_CCMR2_OC4M_2; + Timer->CCER |= TIM_CCER_CC4E; } } diff --git a/Projet_DevDrivers/Sources/Principal.c b/Projet_DevDrivers/Sources/Principal.c index ee1f527..2905c75 100644 --- a/Projet_DevDrivers/Sources/Principal.c +++ b/Projet_DevDrivers/Sources/Principal.c @@ -4,10 +4,11 @@ -void Mafonction_IT (void); +void MyFunction_IT (void); MyGPIO_Struct_TypeDef PA5; +MyGPIO_Struct_TypeDef PA6; MyGPIO_Struct_TypeDef PC13; -MyTimer_Struct_TypeDef timer2; +MyTimer_Struct_TypeDef timer3; //PA5 LED //PC13 Bouton @@ -17,25 +18,32 @@ int main ( void ) PA5.GPIO_Conf=Out_Ppull; PA5.GPIO_Pin=5; MyGPIO_Init(&PA5); - timer2.Timer=TIM2; - timer2.ARR=35999; //pour avoir 500ms - timer2.PSC=1000; - MyTimer_Base_Init(&timer2); - MyTimer_ActiveIT(timer2.Timer,1, &Mafonction_IT); - MyTimer_Base_Start(timer2.Timer); - MyPWM_init (TIM2,1); - MyPWM_Duty (TIM2,1, 10000); + PA6.GPIO=GPIOA; + PA6.GPIO_Conf=AltOut_Ppull; + PA6.GPIO_Pin=6; + MyGPIO_Init(&PA6); + + timer3.Timer=TIM3; + timer3.ARR=35999; //pour avoir 500ms + timer3.PSC=1000; + MyTimer_Base_Init(&timer3); + MyTimer_ActiveIT(timer3.Timer,1, &MyFunction_IT); + MyTimer_Base_Start(timer3.Timer); + + MyPWM_init (TIM3,1); + MyPWM_Duty (TIM3,1, 10000); while(1) { + } } -void Mafonction_IT (void) +void MyFunction_IT (void) { MyGPIO_Toggle(PA5.GPIO,5); } diff --git a/Projet_DevDrivers/TP1.uvoptx b/Projet_DevDrivers/TP1.uvoptx index 4020d24..b161828 100644 --- a/Projet_DevDrivers/TP1.uvoptx +++ b/Projet_DevDrivers/TP1.uvoptx @@ -125,7 +125,7 @@ 0 DLGDARM - (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=733,260,1154,687,0)(121=-1,-1,-1,-1,0)(122=1345,565,1766,992,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=1189,292,1783,1043,1)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=873,10,1294,437,1)(121=-1,-1,-1,-1,0)(122=1345,565,1766,992,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=862,435,1456,1186,0)(132=870,423,1464,1174,1)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) 0 @@ -159,7 +159,7 @@ 0 0 0 - 1 + 0 0 0 0 @@ -188,16 +188,6 @@ FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254412026203078303030303030323029203E3E2035000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F170000000000000000000000000000000000000090020008 - - - System Viewer\ADC1 - 35905 - - - System Viewer\TIM2 - 35904 - - 1 1