diff --git a/Drivers/Include/Driver_Timer.h b/Drivers/Include/Driver_Timer.h
index 150a211..fdd102f 100644
--- a/Drivers/Include/Driver_Timer.h
+++ b/Drivers/Include/Driver_Timer.h
@@ -14,7 +14,7 @@ typedef struct
void MyTimer_Base_Init(MyTimer_Struct_TypeDef * Timer);
void MyTimer_Base_Start(TIM_TypeDef * Timer);
void MyTimer_Base_Stop(TIM_TypeDef * Timer);
-
+void MyTimer_PWM( MyTimer_Struct_TypeDef * Timer, uint16_t cycle);
/*#define MyTimer_Base_Start(Timer)
#define MyTimer_Base_Stop(Timer)
diff --git a/Drivers/Sources/Driver_Timer.c b/Drivers/Sources/Driver_Timer.c
index 338e3e7..678672a 100644
--- a/Drivers/Sources/Driver_Timer.c
+++ b/Drivers/Sources/Driver_Timer.c
@@ -36,3 +36,11 @@ void MyTimer_Base_Stop(TIM_TypeDef * Timer){
}
+void MyTimer_PWM( MyTimer_Struct_TypeDef * Timer, uint16_t cycle){
+ Timer->Timer->CCMR1 &= ~TIM_CCMR1_OC1M_0; //Configuration du canal CH1
+ Timer->Timer->CCMR1 |= TIM_CCMR1_OC1M_1| TIM_CCMR1_OC1M_2; // Ajouter 110 aux bits OC1M (registre CCMR1)
+
+ Timer->Timer->CCER |= TIM_CCER_CC1E; // Canal CH1 validé par bit CC1E (registre CCER)
+ Timer->Timer->CR1 |= TIM_CR1_CEN; // Lancement du timer
+ Timer->Timer->CCR1 = (cycle * Timer->ARR) / 100; // Fixer la durée à 20%
+}
diff --git a/GPIO_Test/GPIO_Test.uvoptx b/GPIO_Test/GPIO_Test.uvoptx
index da94ef5..cfed698 100644
--- a/GPIO_Test/GPIO_Test.uvoptx
+++ b/GPIO_Test/GPIO_Test.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=297,604,718,1031,0)(121=-1,-1,-1,-1,0)(122=546,289,967,716,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=997,343,1591,1094,0)(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=297,604,718,1031,0)(121=-1,-1,-1,-1,0)(122=546,289,967,716,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=911,135,1505,886,0)(131=997,343,1591,1094,0)(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)
0
@@ -150,7 +150,7 @@
0
1
- 1
+ 0
0
0
0
@@ -158,13 +158,13 @@
1
0
0
- 1
+ 0
0
0
0
0
0
- 1
+ 0
0
0
0
@@ -193,12 +193,6 @@
FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028504F5254412026203078303030303030323029203E3E2035000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1700000000000000000000000000000000000000DA040008
-
-
- System Viewer\GPIOA
- 35905
-
-
1
0
diff --git a/GPIO_Test/Sources/Main.c b/GPIO_Test/Sources/Main.c
index 70dd82b..8d83a8c 100644
--- a/GPIO_Test/Sources/Main.c
+++ b/GPIO_Test/Sources/Main.c
@@ -21,20 +21,20 @@ int main (void){
MyGPIO_Init (&BP);
//Init Timer 2 et Test
TIM500ms.Timer = TIM2;
- TIM500ms.PSC = 0xD2F0; // =0.5ms(calculé à partir de la fréquence du micro)
- TIM500ms.ARR = 1000;
+ TIM500ms.PSC = 7200; // =0.5ms(calculé à partir de la fréquence du micro)
+ TIM500ms.ARR = 5000;
MyTimer_Base_Init(&TIM500ms);
-
+ /*
TIM2->DIER |= 1<< 0 ; //INTERRUPTION PERIPH
//TIM2->DIER |= TIM_DIER_UIE ;
NVIC->ISER[0] |= 1<IP[TIM2_IRQn] = 2<< 4 ;
-
+ */
MyTimer_Base_Start(TIM500ms.Timer);
//Boucle infinie de la réponse de la LED à l'état BP
-
+ MyTimer_PWM(&TIM500ms, 50);
while(1){
// if (MyGPIO_Read(BP.GPIO,BP.GPIO_Pin)==0){
@@ -46,9 +46,10 @@ int main (void){
}
}
-
+/*
void TIM2_IRQHandler (void)
{
MyGPIO_Toggle(GPIOA,5);
TIM2->SR &= ~(1<<0);
}
+*/
\ No newline at end of file