From f47e05482f69fea8641337000593d6aa7edd0d7a Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Tue, 21 Mar 2023 19:54:54 +0100 Subject: [PATCH] PWM foncitonnal (tested for Timer2 -> Channel 2), need to do a generic library tho. --- .../timer_interruption/Source/Principale.c | 9 ++-- .../timer_interruption.uvoptx | 6 +-- .../timer_interruption.uvprojx | 44 ++++++++++--------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/ProjetsKEIL/timer_interruption/Source/Principale.c b/ProjetsKEIL/timer_interruption/Source/Principale.c index 6636faa..b4ffeeb 100644 --- a/ProjetsKEIL/timer_interruption/Source/Principale.c +++ b/ProjetsKEIL/timer_interruption/Source/Principale.c @@ -2,6 +2,8 @@ #include "../../Drivers/gpiodriver.h" #include "../../Drivers/timerdriver.h" +#define MOE 0x15 + void ToggleLed(void) { MyGPIO_Toggle(GPIOA,5); @@ -24,9 +26,10 @@ int main (void) MyTimer_ActiveIT(TIM2,2); //PWM enable - TIM2->BDTR |= (1<<1); // MOE A FAIRE - TIM2->CCR1 = 400; - TIM2->CCER |= (1<<0); + TIM2->CCMR1 |= (0x6<<12); + TIM2->BDTR |= (1<CCR2 = 10; + TIM2->CCER |= (1<<4); //0 pour CC1E, 4 pour CC2P do{ }while(1) ; diff --git a/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx b/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx index 6c4a8ff..09beeee 100644 --- a/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx +++ b/ProjetsKEIL/timer_interruption/timer_interruption.uvoptx @@ -125,7 +125,7 @@ 0 DLGDARM - (1010=895,198,1271,755,1)(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=486,94,907,521,1)(121=464,533,885,960,1)(122=875,109,1296,536,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=1326,229,1920,980,1)(132=150,186,744,937,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=895,198,1271,755,1)(1007=105,137,292,412,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=498,100,919,527,1)(121=491,538,912,965,1)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=105,137,504,482,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=1175,164,1769,915,1)(132=150,186,744,937,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 @@ -312,7 +312,7 @@ 0 ST-LINKIII-KEIL_SWO - -U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) + -U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 0 @@ -422,7 +422,7 @@ 1 2 1 - 1 + 0 0 0 ..\Drivers\gpiodriver.c diff --git a/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx b/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx index 4c6498b..69b2308 100644 --- a/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx +++ b/ProjetsKEIL/timer_interruption/timer_interruption.uvprojx @@ -10,13 +10,14 @@ Simulé 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARMCC - 0 + 6190000::V6.19::ARMCLANG + 6190000::V6.19::ARMCLANG + 1 STM32F103RB STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.4.0 http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE @@ -134,11 +135,11 @@ 0 1 1 - -1 + 4096 1 BIN\UL2CM3.DLL - + "" () @@ -186,6 +187,7 @@ 0 0 0 + 0 0 0 8 @@ -313,7 +315,7 @@ 1 - 1 + 2 0 0 1 @@ -322,7 +324,7 @@ 0 0 0 - 2 + 3 0 0 0 @@ -415,13 +417,14 @@ Réel 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARMCC - 0 + 6190000::V6.19::ARMCLANG + 6190000::V6.19::ARMCLANG + 1 STM32F103RB STMicroelectronics - Keil.STM32F1xx_DFP.2.3.0 + Keil.STM32F1xx_DFP.2.4.0 http://www.keil.com/pack/ IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE @@ -539,11 +542,11 @@ 0 1 1 - -1 + 4096 1 BIN\UL2CM3.DLL - + "" () @@ -591,6 +594,7 @@ 0 0 0 + 0 0 0 8 @@ -718,7 +722,7 @@ 1 - 1 + 2 0 0 1 @@ -727,7 +731,7 @@ 0 0 0 - 2 + 3 0 0 0 @@ -821,15 +825,15 @@ - - + + - + @@ -840,7 +844,7 @@ RTE\Device\STM32F103RB\RTE_Device.h - + @@ -849,7 +853,7 @@ RTE\Device\STM32F103RB\startup_stm32f10x_md.s - + @@ -858,7 +862,7 @@ RTE\Device\STM32F103RB\system_stm32f10x.c - +