Browse Source

GPIO configuration fixed - Moteur OK

Neluji 3 years ago
parent
commit
3aa8003776
5 changed files with 45 additions and 39 deletions
  1. 6
    22
      MDK-ARM/Project.uvoptx
  2. 6
    2
      MyDrivers/MyPWM.h
  3. 17
    12
      Services/Moteur.c
  4. 6
    0
      Services/Moteur.h
  5. 10
    3
      Src/main.c

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

@@ -354,9 +354,9 @@
354 354
         <Bp>
355 355
           <Number>0</Number>
356 356
           <Type>0</Type>
357
-          <LineNumber>38</LineNumber>
357
+          <LineNumber>25</LineNumber>
358 358
           <EnabledFlag>1</EnabledFlag>
359
-          <Address>134219162</Address>
359
+          <Address>134219120</Address>
360 360
           <ByteObject>0</ByteObject>
361 361
           <HtxType>0</HtxType>
362 362
           <ManyObjects>0</ManyObjects>
@@ -365,23 +365,7 @@
365 365
           <BreakIfRCount>1</BreakIfRCount>
366 366
           <Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
367 367
           <ExecCommand></ExecCommand>
368
-          <Expression>\\NUCLEO_F103RB\../Services/Moteur.c\38</Expression>
369
-        </Bp>
370
-        <Bp>
371
-          <Number>1</Number>
372
-          <Type>0</Type>
373
-          <LineNumber>26</LineNumber>
374
-          <EnabledFlag>1</EnabledFlag>
375
-          <Address>134219126</Address>
376
-          <ByteObject>0</ByteObject>
377
-          <HtxType>0</HtxType>
378
-          <ManyObjects>0</ManyObjects>
379
-          <SizeOfObject>0</SizeOfObject>
380
-          <BreakByAccess>0</BreakByAccess>
381
-          <BreakIfRCount>1</BreakIfRCount>
382
-          <Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
383
-          <ExecCommand></ExecCommand>
384
-          <Expression>\\NUCLEO_F103RB\../Services/Moteur.c\26</Expression>
368
+          <Expression>\\NUCLEO_F103RB\../Services/Moteur.c\25</Expression>
385 369
         </Bp>
386 370
       </Breakpoint>
387 371
       <WatchWindow1>
@@ -395,7 +379,7 @@
395 379
         <Mm>
396 380
           <WinNumber>1</WinNumber>
397 381
           <SubType>0</SubType>
398
-          <ItemText>Psc</ItemText>
382
+          <ItemText>My_GPIO_Init_Struct</ItemText>
399 383
           <AccSizeX>0</AccSizeX>
400 384
         </Mm>
401 385
       </MemoryWindow1>
@@ -445,12 +429,12 @@
445 429
         <Wi>
446 430
           <IntNumber>0</IntNumber>
447 431
           <FirstString>((porta &amp; 0x00000002) &gt;&gt; 1 &amp; 0x2) &gt;&gt; 1</FirstString>
448
-          <SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
432
+          <SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
449 433
         </Wi>
450 434
         <Wi>
451 435
           <IntNumber>1</IntNumber>
452 436
           <FirstString>((porta &amp; 0x00000004) &gt;&gt; 2 &amp; 0x4) &gt;&gt; 2</FirstString>
453
-          <SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
437
+          <SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
454 438
         </Wi>
455 439
       </LogicAnalyzers>
456 440
       <DebugDescription>

+ 6
- 2
MyDrivers/MyPWM.h View File

@@ -1,5 +1,7 @@
1
-#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
2
-#include "stm32f1xx_ll_tim.h"
1
+#ifndef PWM_H
2
+#define PWM_H
3
+
4
+#include "stm32f103xb.h"
3 5
 
4 6
 
5 7
 void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
@@ -7,3 +9,5 @@ void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
7 9
 void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
8 10
 
9 11
 void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel);
12
+
13
+#endif

+ 17
- 12
Services/Moteur.c View File

@@ -1,13 +1,16 @@
1
+
1 2
 #include "Moteur.h"
2 3
 #include "MyPWM.h"
3 4
 #include "MyTimer.h"
4 5
 
5 6
 #include "stm32f1xx_ll_bus.h"
6 7
 #include "stm32f1xx_ll_gpio.h"
8
+#include "stm32f1xx_ll_tim.h"
7 9
 
8
-//Fpwm = 10kHz
9 10
 
10 11
 void Moteur_Conf(void) {
12
+	
13
+	//Fpwm = 10kHz = 72Mhz/(7200 = 0x1C20)
11 14
 	int Arr = 0x1C1F;
12 15
 	int Psc = 0x0;
13 16
 	
@@ -15,24 +18,26 @@ void Moteur_Conf(void) {
15 18
 	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
16 19
 	
17 20
 	//Config broche PA2 -> Sens
18
-	LL_GPIO_InitTypeDef* My_GPIO_Init_Struct;
21
+	LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
19 22
 	
20
-	LL_GPIO_StructInit(My_GPIO_Init_Struct);
23
+	LL_GPIO_StructInit(&My_GPIO_Init_Struct);
21 24
 	
22
-	My_GPIO_Init_Struct->Pin = LL_GPIO_PIN_2;
23
-	My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_OUTPUT;
24
-	My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
25
+	My_GPIO_Init_Struct.Pin = PinSens;
26
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
27
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
25 28
 	
26
-	LL_GPIO_Init(GPIOA, My_GPIO_Init_Struct);
29
+	LL_GPIO_Init(GPIOPins, &My_GPIO_Init_Struct);
27 30
 	
28 31
 	//Config broche PA1 -> PWM
29
-	LL_GPIO_StructInit(My_GPIO_Init_Struct);
32
+	LL_GPIO_StructInit(&My_GPIO_Init_Struct);
33
+	
34
+	My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_1;
35
+	My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
36
+	My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
37
+	
38
+	LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
30 39
 	
31
-	My_GPIO_Init_Struct->Pin = LL_GPIO_PIN_1;
32
-	My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_ALTERNATE;
33
-	My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
34 40
 	
35
-	LL_GPIO_Init(GPIOA, My_GPIO_Init_Struct);
36 41
 	
37 42
 	//Activation horloge Timer
38 43
 	LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);

+ 6
- 0
Services/Moteur.h View File

@@ -1,3 +1,7 @@
1
+#ifndef MOTEUR_H
2
+#define MOTEUR_H
3
+
4
+#include "stm32f103xb.h" 
1 5
 
2 6
 #define PinSens LL_GPIO_PIN_2
3 7
 #define PinPWM LL_GPIO_PIN_1
@@ -10,3 +14,5 @@ void Moteur_Conf(void);
10 14
 void Moteur_Speed(int speedPercentage);
11 15
 
12 16
 void Moteur_Sens(int sens);
17
+
18
+#endif

+ 10
- 3
Src/main.c View File

@@ -45,13 +45,20 @@ int main(void)
45 45
 	//INIT GPIO MARCHE PAS->PB PIN
46 46
 	Moteur_Conf();
47 47
 	
48
-	Moteur_Speed(50);
49
-	Moteur_Sens(1);
48
+	Moteur_Speed(30);
49
+	Moteur_Sens(0);
50 50
   
51 51
   /* Infinite loop */
52
-  while (1)
52
+  for (int i =0; i<0xFFFF; i++)
53 53
   {
54 54
   }
55
+	
56
+	Moteur_Speed(60);
57
+	Moteur_Sens(1);
58
+	
59
+	while (1)
60
+	{
61
+	}
55 62
 }
56 63
 
57 64
 

Loading…
Cancel
Save