GPIO configuration fixed - Moteur OK
This commit is contained in:
parent
7e745ca4f9
commit
3aa8003776
5 changed files with 45 additions and 39 deletions
|
@ -354,9 +354,9 @@
|
||||||
<Bp>
|
<Bp>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Type>0</Type>
|
<Type>0</Type>
|
||||||
<LineNumber>38</LineNumber>
|
<LineNumber>25</LineNumber>
|
||||||
<EnabledFlag>1</EnabledFlag>
|
<EnabledFlag>1</EnabledFlag>
|
||||||
<Address>134219162</Address>
|
<Address>134219120</Address>
|
||||||
<ByteObject>0</ByteObject>
|
<ByteObject>0</ByteObject>
|
||||||
<HtxType>0</HtxType>
|
<HtxType>0</HtxType>
|
||||||
<ManyObjects>0</ManyObjects>
|
<ManyObjects>0</ManyObjects>
|
||||||
|
@ -365,23 +365,7 @@
|
||||||
<BreakIfRCount>1</BreakIfRCount>
|
<BreakIfRCount>1</BreakIfRCount>
|
||||||
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
|
<Filename>F:\Etudes\4A\µC - Périphériques\Periph-Voilier\Services\Moteur.c</Filename>
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\NUCLEO_F103RB\../Services/Moteur.c\38</Expression>
|
<Expression>\\NUCLEO_F103RB\../Services/Moteur.c\25</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>
|
|
||||||
</Bp>
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
|
@ -395,7 +379,7 @@
|
||||||
<Mm>
|
<Mm>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<SubType>0</SubType>
|
<SubType>0</SubType>
|
||||||
<ItemText>Psc</ItemText>
|
<ItemText>My_GPIO_Init_Struct</ItemText>
|
||||||
<AccSizeX>0</AccSizeX>
|
<AccSizeX>0</AccSizeX>
|
||||||
</Mm>
|
</Mm>
|
||||||
</MemoryWindow1>
|
</MemoryWindow1>
|
||||||
|
@ -445,12 +429,12 @@
|
||||||
<Wi>
|
<Wi>
|
||||||
<IntNumber>0</IntNumber>
|
<IntNumber>0</IntNumber>
|
||||||
<FirstString>((porta & 0x00000002) >> 1 & 0x2) >> 1</FirstString>
|
<FirstString>((porta & 0x00000002) >> 1 & 0x2) >> 1</FirstString>
|
||||||
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
|
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
|
||||||
</Wi>
|
</Wi>
|
||||||
<Wi>
|
<Wi>
|
||||||
<IntNumber>1</IntNumber>
|
<IntNumber>1</IntNumber>
|
||||||
<FirstString>((porta & 0x00000004) >> 2 & 0x4) >> 2</FirstString>
|
<FirstString>((porta & 0x00000004) >> 2 & 0x4) >> 2</FirstString>
|
||||||
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
|
<SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F0B00000000000000000000000000000000000000320F0008</SecondString>
|
||||||
</Wi>
|
</Wi>
|
||||||
</LogicAnalyzers>
|
</LogicAnalyzers>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
#ifndef PWM_H
|
||||||
#include "stm32f1xx_ll_tim.h"
|
#define PWM_H
|
||||||
|
|
||||||
|
#include "stm32f103xb.h"
|
||||||
|
|
||||||
|
|
||||||
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
|
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_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
|
||||||
|
|
||||||
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel);
|
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, uint32_t CompareValue, int channel);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
|
|
||||||
#include "Moteur.h"
|
#include "Moteur.h"
|
||||||
#include "MyPWM.h"
|
#include "MyPWM.h"
|
||||||
#include "MyTimer.h"
|
#include "MyTimer.h"
|
||||||
|
|
||||||
#include "stm32f1xx_ll_bus.h"
|
#include "stm32f1xx_ll_bus.h"
|
||||||
#include "stm32f1xx_ll_gpio.h"
|
#include "stm32f1xx_ll_gpio.h"
|
||||||
|
#include "stm32f1xx_ll_tim.h"
|
||||||
|
|
||||||
//Fpwm = 10kHz
|
|
||||||
|
|
||||||
void Moteur_Conf(void) {
|
void Moteur_Conf(void) {
|
||||||
|
|
||||||
|
//Fpwm = 10kHz = 72Mhz/(7200 = 0x1C20)
|
||||||
int Arr = 0x1C1F;
|
int Arr = 0x1C1F;
|
||||||
int Psc = 0x0;
|
int Psc = 0x0;
|
||||||
|
|
||||||
|
@ -15,24 +18,26 @@ void Moteur_Conf(void) {
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
||||||
|
|
||||||
//Config broche PA2 -> Sens
|
//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.Pin = PinSens;
|
||||||
My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_OUTPUT;
|
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||||
My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
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
|
//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
|
//Activation horloge Timer
|
||||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM2);
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#ifndef MOTEUR_H
|
||||||
|
#define MOTEUR_H
|
||||||
|
|
||||||
|
#include "stm32f103xb.h"
|
||||||
|
|
||||||
#define PinSens LL_GPIO_PIN_2
|
#define PinSens LL_GPIO_PIN_2
|
||||||
#define PinPWM LL_GPIO_PIN_1
|
#define PinPWM LL_GPIO_PIN_1
|
||||||
|
@ -10,3 +14,5 @@ void Moteur_Conf(void);
|
||||||
void Moteur_Speed(int speedPercentage);
|
void Moteur_Speed(int speedPercentage);
|
||||||
|
|
||||||
void Moteur_Sens(int sens);
|
void Moteur_Sens(int sens);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
13
Src/main.c
13
Src/main.c
|
@ -45,13 +45,20 @@ int main(void)
|
||||||
//INIT GPIO MARCHE PAS->PB PIN
|
//INIT GPIO MARCHE PAS->PB PIN
|
||||||
Moteur_Conf();
|
Moteur_Conf();
|
||||||
|
|
||||||
Moteur_Speed(50);
|
Moteur_Speed(30);
|
||||||
Moteur_Sens(1);
|
Moteur_Sens(0);
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
while (1)
|
for (int i =0; i<0xFFFF; i++)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Moteur_Speed(60);
|
||||||
|
Moteur_Sens(1);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue