GPIO configuration fixed - Moteur OK

This commit is contained in:
Neluji 2020-11-22 13:05:16 +01:00
parent 7e745ca4f9
commit 3aa8003776
5 changed files with 45 additions and 39 deletions

View file

@ -354,9 +354,9 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>38</LineNumber>
<LineNumber>25</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219162</Address>
<Address>134219120</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
@ -365,23 +365,7 @@
<BreakIfRCount>1</BreakIfRCount>
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Services/Moteur.c\38</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>26</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219126</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\NUCLEO_F103RB\../Services/Moteur.c\26</Expression>
<Expression>\\NUCLEO_F103RB\../Services/Moteur.c\25</Expression>
</Bp>
</Breakpoint>
<WatchWindow1>
@ -395,7 +379,7 @@
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>Psc</ItemText>
<ItemText>My_GPIO_Init_Struct</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
@ -445,12 +429,12 @@
<Wi>
<IntNumber>0</IntNumber>
<FirstString>((porta &amp; 0x00000002) &gt;&gt; 1 &amp; 0x2) &gt;&gt; 1</FirstString>
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
</Wi>
<Wi>
<IntNumber>1</IntNumber>
<FirstString>((porta &amp; 0x00000004) &gt;&gt; 2 &amp; 0x4) &gt;&gt; 2</FirstString>
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
</Wi>
</LogicAnalyzers>
<DebugDescription>

View file

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

View file

@ -1,13 +1,16 @@
#include "Moteur.h"
#include "MyPWM.h"
#include "MyTimer.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_tim.h"
//Fpwm = 10kHz
void Moteur_Conf(void) {
//Fpwm = 10kHz = 72Mhz/(7200 = 0x1C20)
int Arr = 0x1C1F;
int Psc = 0x0;
@ -15,24 +18,26 @@ void Moteur_Conf(void) {
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
//Config broche PA2 -> Sens
LL_GPIO_InitTypeDef* My_GPIO_Init_Struct;
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
LL_GPIO_StructInit(My_GPIO_Init_Struct);
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
My_GPIO_Init_Struct->Pin = LL_GPIO_PIN_2;
My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_OUTPUT;
My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
My_GPIO_Init_Struct.Pin = PinSens;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, My_GPIO_Init_Struct);
LL_GPIO_Init(GPIOPins, &My_GPIO_Init_Struct);
//Config broche PA1 -> PWM
LL_GPIO_StructInit(My_GPIO_Init_Struct);
LL_GPIO_StructInit(&My_GPIO_Init_Struct);
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_1;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
My_GPIO_Init_Struct->Pin = LL_GPIO_PIN_1;
My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOA, My_GPIO_Init_Struct);
//Activation horloge Timer
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);

View file

@ -1,3 +1,7 @@
#ifndef MOTEUR_H
#define MOTEUR_H
#include "stm32f103xb.h"
#define PinSens LL_GPIO_PIN_2
#define PinPWM LL_GPIO_PIN_1
@ -10,3 +14,5 @@ void Moteur_Conf(void);
void Moteur_Speed(int speedPercentage);
void Moteur_Sens(int sens);
#endif

View file

@ -45,13 +45,20 @@ int main(void)
//INIT GPIO MARCHE PAS->PB PIN
Moteur_Conf();
Moteur_Speed(50);
Moteur_Sens(1);
Moteur_Speed(30);
Moteur_Sens(0);
/* Infinite loop */
while (1)
for (int i =0; i<0xFFFF; i++)
{
}
Moteur_Speed(60);
Moteur_Sens(1);
while (1)
{
}
}