Browse Source

Output ok, + choix canal pour Set_Impulse_Duration

Neluji 3 years ago
parent
commit
6e1c2b1766
4 changed files with 49 additions and 39 deletions
  1. 10
    22
      MDK-ARM/Project.uvoptx
  2. 5
    2
      MyDrivers/MyPWM.c
  3. 1
    1
      MyDrivers/MyPWM.h
  4. 33
    14
      Src/main.c

+ 10
- 22
MDK-ARM/Project.uvoptx View File

@@ -317,7 +317,7 @@
317 317
         <SetRegEntry>
318 318
           <Number>0</Number>
319 319
           <Key>DLGDARM</Key>
320
-          <Name>(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=752,104,972,564,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=98,107,519,534,0)(121=-1,-1,-1,-1,0)(122=674,103,1095,530,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=405,45,999,796,0)(131=-1,-1,-1,-1,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)</Name>
320
+          <Name>(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=504,37,1150,710,0)(110=60,88,280,548,0)(111=752,104,972,564,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=273,112,694,539,0)(121=75,104,496,531,0)(122=674,103,1095,530,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=709,11,1303,762,0)(131=150,13,744,764,0)(132=599,52,1193,803,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)</Name>
321 321
         </SetRegEntry>
322 322
         <SetRegEntry>
323 323
           <Number>0</Number>
@@ -350,24 +350,7 @@
350 350
           <Name>-U-O142 -O2254 -S0 -C0 -A0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)</Name>
351 351
         </SetRegEntry>
352 352
       </TargetDriverDllRegistry>
353
-      <Breakpoint>
354
-        <Bp>
355
-          <Number>0</Number>
356
-          <Type>0</Type>
357
-          <LineNumber>42</LineNumber>
358
-          <EnabledFlag>1</EnabledFlag>
359
-          <Address>134221314</Address>
360
-          <ByteObject>0</ByteObject>
361
-          <HtxType>0</HtxType>
362
-          <ManyObjects>0</ManyObjects>
363
-          <SizeOfObject>0</SizeOfObject>
364
-          <BreakByAccess>0</BreakByAccess>
365
-          <BreakIfRCount>1</BreakIfRCount>
366
-          <Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Src\main.c</Filename>
367
-          <ExecCommand></ExecCommand>
368
-          <Expression>\\NUCLEO_F103RB\../Src/main.c\42</Expression>
369
-        </Bp>
370
-      </Breakpoint>
353
+      <Breakpoint/>
371 354
       <WatchWindow1>
372 355
         <Ww>
373 356
           <count>0</count>
@@ -379,7 +362,7 @@
379 362
         <Mm>
380 363
           <WinNumber>1</WinNumber>
381 364
           <SubType>0</SubType>
382
-          <ItemText>0x080005D3</ItemText>
365
+          <ItemText>0x04010001</ItemText>
383 366
           <AccSizeX>0</AccSizeX>
384 367
         </Mm>
385 368
       </MemoryWindow1>
@@ -428,8 +411,13 @@
428 411
       <LogicAnalyzers>
429 412
         <Wi>
430 413
           <IntNumber>0</IntNumber>
431
-          <FirstString>((porta &amp; 0x00000100) &gt;&gt; 8 &amp; 0x100) &gt;&gt; 8</FirstString>
432
-          <SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303031303029203E3E2038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1600000000000000000000000000000000000000040C0008</SecondString>
414
+          <FirstString>((porta &amp; 0x00000080) &gt;&gt; 7 &amp; 0x80) &gt;&gt; 7</FirstString>
415
+          <SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030383029203E3E2037000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F1800000000000000000000000000000000000000540E0008</SecondString>
416
+        </Wi>
417
+        <Wi>
418
+          <IntNumber>1</IntNumber>
419
+          <FirstString>((portb &amp; 0x00000200) &gt;&gt; 9 &amp; 0x200) &gt;&gt; 9</FirstString>
420
+          <SecondString>00000000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274622026203078303030303032303029203E3E2039000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F1800000000000000000000000000000000000000540E0008</SecondString>
433 421
         </Wi>
434 422
       </LogicAnalyzers>
435 423
       <DebugDescription>

+ 5
- 2
MyDrivers/MyPWM.c View File

@@ -47,9 +47,12 @@ void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2)
47 47
 }
48 48
 
49 49
 
50
-void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage)
50
+void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel)
51 51
 {
52 52
 	uint32_t CompareValue = 0xFFFF * Percentage/100;
53
-	LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
53
+	if (channel==LL_TIM_CHANNEL_CH1) LL_TIM_OC_SetCompareCH1(Timer, CompareValue);
54
+	else if (channel==LL_TIM_CHANNEL_CH2) LL_TIM_OC_SetCompareCH2(Timer, CompareValue);
55
+	else if (channel==LL_TIM_CHANNEL_CH3) LL_TIM_OC_SetCompareCH3(Timer, CompareValue);
56
+	else  LL_TIM_OC_SetCompareCH4(Timer, CompareValue);
54 57
 }
55 58
 

+ 1
- 1
MyDrivers/MyPWM.h View File

@@ -6,4 +6,4 @@ void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
6 6
 
7 7
 void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
8 8
 
9
-void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage);
9
+void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage, int channel);

+ 33
- 14
Src/main.c View File

@@ -39,24 +39,43 @@ int main(void)
39 39
   /* Configure the system clock to 72 MHz */
40 40
   SystemClock_Config();
41 41
 	
42
-	MyTimer_Conf(TIM1,999, 719);
42
+	/*===Test Output===*/
43 43
 	
44
-	MyPWM_Conf_Output(TIM1, LL_TIM_CHANNEL_CH1);
44
+	TIM_TypeDef *Timer1 = TIM3;
45
+	int Channel1 = LL_TIM_CHANNEL_CH2;
46
+	TIM_TypeDef *Timer2 = TIM4;
47
+	int Channel2 = LL_TIM_CHANNEL_CH4;
45 48
 	
46
-	MyPWM_Set_Impulse_Duration(TIM1, 25);
49
+	MyTimer_Conf(Timer1,0xFFFE, 0x72);
50
+	MyTimer_Conf(Timer2,0xFFFE, 0x72);
47 51
 	
48
-//	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
49
-//	GPIO_TypeDef * GPIO;
50
-//	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;	
51
-//	GPIO = GPIOA;
52
-//	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_8;
53
-//	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
54
-//	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
55
-//	My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_10MHz;
56
-//	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
57
-//	LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
52
+	MyPWM_Conf_Output(Timer1, Channel1);
53
+	MyPWM_Conf_Output(Timer2, Channel2);
58 54
 	
59
-	MyTimer_Start(TIM1);
55
+	MyPWM_Set_Impulse_Duration(Timer1, 25, Channel1);
56
+	MyPWM_Set_Impulse_Duration(Timer2, 75, Channel2);
57
+	
58
+	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
59
+	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
60
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7;
61
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
62
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
63
+	My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz;
64
+	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
65
+	LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
66
+	
67
+	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
68
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_9;
69
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
70
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
71
+	My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz;
72
+	My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
73
+	LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
74
+	
75
+	MyTimer_Start(Timer1);
76
+	MyTimer_Start(Timer2);
77
+
78
+
60 79
   
61 80
   /* Infinite loop */
62 81
   while (1)

Loading…
Cancel
Save