Fin séance 10 -> pb conf gpio

This commit is contained in:
Neluji 2020-11-17 11:09:17 +01:00
parent 506c519386
commit 7e745ca4f9
5 changed files with 65 additions and 69 deletions

View file

@ -305,7 +305,7 @@
<sDllPa></sDllPa> <sDllPa></sDllPa>
<sDlgDll></sDlgDll> <sDlgDll></sDlgDll>
<sDlgPa></sDlgPa> <sDlgPa></sDlgPa>
<sIfile>..\..\inifiles\Simu_Pulse.ini</sIfile> <sIfile></sIfile>
<tDll></tDll> <tDll></tDll>
<tDllPa></tDllPa> <tDllPa></tDllPa>
<tDlgDll></tDlgDll> <tDlgDll></tDlgDll>
@ -317,7 +317,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>DLGDARM</Key> <Key>DLGDARM</Key>
<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=533,85,954,512,0)(121=892,96,1313,523,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,17,1193,768,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> <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=864,64,1285,491,0)(121=892,96,1313,523,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=736,17,1330,768,0)(132=599,17,1193,768,0)(133=295,17,889,768,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>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -350,7 +350,40 @@
<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> <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>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint/> <Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>38</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219162</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\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>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -362,7 +395,7 @@
<Mm> <Mm>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<SubType>0</SubType> <SubType>0</SubType>
<ItemText>porta</ItemText> <ItemText>Psc</ItemText>
<AccSizeX>0</AccSizeX> <AccSizeX>0</AccSizeX>
</Mm> </Mm>
</MemoryWindow1> </MemoryWindow1>
@ -411,18 +444,13 @@
<LogicAnalyzers> <LogicAnalyzers>
<Wi> <Wi>
<IntNumber>0</IntNumber> <IntNumber>0</IntNumber>
<FirstString>((porta &amp; 0x00000080) &gt;&gt; 7 &amp; 0x80) &gt;&gt; 7</FirstString> <FirstString>((porta &amp; 0x00000002) &gt;&gt; 1 &amp; 0x2) &gt;&gt; 1</FirstString>
<SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030383029203E3E2037000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000CDCCCCCCCCCCD43F1800000000000000000000000000000000000000540E0008</SecondString> <SecondString>00800000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
</Wi> </Wi>
<Wi> <Wi>
<IntNumber>1</IntNumber> <IntNumber>1</IntNumber>
<FirstString>(porta &amp; 0x00000001)</FirstString> <FirstString>((porta &amp; 0x00000004) &gt;&gt; 2 &amp; 0x4) &gt;&gt; 2</FirstString>
<SecondString>00000000000000000000000000000000E0FFEF400100000000000000000000000000000028706F72746120262030783030303030303031290000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000D43F1800000000000000000000000000000000000000E20E0008</SecondString> <SecondString>00008000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303030303429203E3E2032000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000002000000000000000000E03F1800000000000000000000000000000000000000320F0008</SecondString>
</Wi>
<Wi>
<IntNumber>2</IntNumber>
<FirstString>((portb &amp; 0x00000040) &gt;&gt; 6 &amp; 0x40) &gt;&gt; 6</FirstString>
<SecondString>00008000000000000000000000000000E0FFEF400000000000000000000000000000000028706F7274622026203078303030303030343029203E3E2036000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000003000000333333333333D73F1800000000000000000000000000000000000000440E0008</SecondString>
</Wi> </Wi>
</LogicAnalyzers> </LogicAnalyzers>
<DebugDescription> <DebugDescription>
@ -465,7 +493,7 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>2</FileNumber> <FileNumber>2</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\Services\Moteur.c</PathWithFileName> <PathWithFileName>..\Services\Moteur.c</PathWithFileName>

View file

@ -6,10 +6,10 @@
#include "stm32f1xx_ll_gpio.h" #include "stm32f1xx_ll_gpio.h"
//Fpwm = 10kHz //Fpwm = 10kHz
static int Arr = 0x1C1F;
static int Psc = 0x0;
void Moteur_Conf() { void Moteur_Conf(void) {
int Arr = 0x1C1F;
int Psc = 0x0;
//Activation horloge GPIO //Activation horloge GPIO
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
@ -19,20 +19,20 @@ void Moteur_Conf() {
LL_GPIO_StructInit(My_GPIO_Init_Struct); LL_GPIO_StructInit(My_GPIO_Init_Struct);
My_GPIO_Init_Struct->Pin = PinSens; My_GPIO_Init_Struct->Pin = LL_GPIO_PIN_2;
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(GPIOPins, My_GPIO_Init_Struct); LL_GPIO_Init(GPIOA, 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 = PinPWM; My_GPIO_Init_Struct->Pin = LL_GPIO_PIN_1;
My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_ALTERNATE; My_GPIO_Init_Struct->Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL; My_GPIO_Init_Struct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
LL_GPIO_Init(GPIOPins, My_GPIO_Init_Struct); 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);
@ -41,13 +41,16 @@ void Moteur_Conf() {
MyTimer_Conf(TimerPWM, Arr, Psc); MyTimer_Conf(TimerPWM, Arr, Psc);
//Configuration du Timer en PWM Output //Configuration du Timer en PWM Output
MyPWM_Conf_Output(TimerPWM, channelPWM); MyPWM_Conf_Output(TimerPWM, channelPWM);
MyPWM_Set_Impulse_Duration(TimerPWM, 0, channelPWM);
Moteur_Speed(0);
Moteur_Sens(0);
} }
void Moteur_Speed(int speedPercentage) { void Moteur_Speed(int speedPercentage) {
int Arr = 0x1C1F;
if(speedPercentage == 0) { if(speedPercentage == 0) {
MyTimer_Stop(TimerPWM); MyTimer_Stop(TimerPWM);
@ -69,4 +72,4 @@ void Moteur_Sens(int sens) {
LL_GPIO_SetOutputPin(GPIOPins, PinSens); LL_GPIO_SetOutputPin(GPIOPins, PinSens);
} }
} }

View file

@ -4,3 +4,9 @@
#define GPIOPins GPIOA #define GPIOPins GPIOA
#define TimerPWM TIM2 #define TimerPWM TIM2
#define channelPWM LL_TIM_CHANNEL_CH2 #define channelPWM LL_TIM_CHANNEL_CH2
void Moteur_Conf(void);
void Moteur_Speed(int speedPercentage);
void Moteur_Sens(int sens);

View file

@ -1 +0,0 @@
Mettre les services ici

View file

@ -40,53 +40,13 @@ int main(void)
/* Configure the system clock to 72 MHz */ /* Configure the system clock to 72 MHz */
SystemClock_Config(); SystemClock_Config();
/*===Test Output===*/ /*===Test Moteur===*/
TIM_TypeDef *Timer1 = TIM3; //INIT GPIO MARCHE PAS->PB PIN
int Channel1 = LL_TIM_CHANNEL_CH2; Moteur_Conf();
TIM_TypeDef *Timer2 = TIM4;
int Channel2 = LL_TIM_CHANNEL_CH4;
MyTimer_Conf(Timer1,0xFFFE, 0x72); Moteur_Speed(50);
MyTimer_Conf(Timer2,0xFFFE, 0x72); Moteur_Sens(1);
MyPWM_Conf_Output(Timer1, Channel1);
MyPWM_Conf_Output(Timer2, Channel2);
MyPWM_Set_Impulse_Duration(Timer1, 25, Channel1);
MyPWM_Set_Impulse_Duration(Timer2, 75, Channel2);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_7;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB);
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_9;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_ALTERNATE;
My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_2MHz;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_0;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOA, &My_GPIO_Init_Struct);
My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_6;
My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_FLOATING;
My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
LL_GPIO_Init(GPIOB, &My_GPIO_Init_Struct);
MyTimer_Start(Timer1);
MyTimer_Start(Timer2);
/* Infinite loop */ /* Infinite loop */
while (1) while (1)