PWM input
This commit is contained in:
parent
325154c167
commit
11a7310a43
6 changed files with 58 additions and 21 deletions
|
@ -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=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,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=-1,-1,-1,-1,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>
|
<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=-1,-1,-1,-1,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=273,213,867,964,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>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
<AscS3>0</AscS3>
|
<AscS3>0</AscS3>
|
||||||
<aSer3>0</aSer3>
|
<aSer3>0</aSer3>
|
||||||
<eProf>0</eProf>
|
<eProf>0</eProf>
|
||||||
<aLa>0</aLa>
|
<aLa>1</aLa>
|
||||||
<aPa1>0</aPa1>
|
<aPa1>0</aPa1>
|
||||||
<AscS4>0</AscS4>
|
<AscS4>0</AscS4>
|
||||||
<aSer4>0</aSer4>
|
<aSer4>0</aSer4>
|
||||||
|
@ -400,6 +400,13 @@
|
||||||
<pszMrulep></pszMrulep>
|
<pszMrulep></pszMrulep>
|
||||||
<pSingCmdsp></pSingCmdsp>
|
<pSingCmdsp></pSingCmdsp>
|
||||||
<pMultCmdsp></pMultCmdsp>
|
<pMultCmdsp></pMultCmdsp>
|
||||||
|
<LogicAnalyzers>
|
||||||
|
<Wi>
|
||||||
|
<IntNumber>0</IntNumber>
|
||||||
|
<FirstString>((porta & 0x00000100) >> 8 & 0x100) >> 8</FirstString>
|
||||||
|
<SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274612026203078303030303031303029203E3E2038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1A00000000000000000000000000000000000000040C0008</SecondString>
|
||||||
|
</Wi>
|
||||||
|
</LogicAnalyzers>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
<Enable>1</Enable>
|
<Enable>1</Enable>
|
||||||
<EnableFlashSeq>0</EnableFlashSeq>
|
<EnableFlashSeq>0</EnableFlashSeq>
|
||||||
|
|
|
@ -2,36 +2,48 @@
|
||||||
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
||||||
#include "stm32f1xx_ll_tim.h"
|
#include "stm32f1xx_ll_tim.h"
|
||||||
|
|
||||||
//Seul le channel CH1 des timers sera utilisé
|
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel)
|
||||||
int channel = LL_TIM_CHANNEL_CH1;
|
|
||||||
|
|
||||||
void MyPWM_Conf_Output(TIM_TypeDef * Timer)
|
|
||||||
{
|
{
|
||||||
//Activation du channel (CH1) pour le timer considéré
|
//Activation du channel pour le timer considéré
|
||||||
LL_TIM_CC_EnableChannel(Timer, channel);
|
LL_TIM_CC_EnableChannel(Timer, channel);
|
||||||
|
|
||||||
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
|
LL_TIM_OC_InitTypeDef My_LL_Tim_OC_Init_Struct;
|
||||||
|
|
||||||
//Configuration du output channel en PWM
|
//Configuration du output channel en PWM
|
||||||
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
|
LL_TIM_OC_StructInit(&My_LL_Tim_OC_Init_Struct);
|
||||||
|
//Configure le mode de la PWM : PWM1 = 1 jusqu'à la CompareValue puis 0, PWM2 = l'inverse
|
||||||
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
|
My_LL_Tim_OC_Init_Struct.OCMode = LL_TIM_OCMODE_PWM1;
|
||||||
|
|
||||||
LL_TIM_OC_Init(Timer,channel,&My_LL_Tim_OC_Init_Struct);
|
LL_TIM_OC_Init(Timer,channel,&My_LL_Tim_OC_Init_Struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Configurer obligatoirement les channels 1 et 2 sur IC1 et IC2 ou IC3 et IC4
|
||||||
void MyPWM_Conf_Input(TIM_TypeDef * Timer)
|
void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2)
|
||||||
{
|
{
|
||||||
//Activation du channel (CH1) pour le timer considéré
|
//Activation des 2 channels pour le timer considéré
|
||||||
LL_TIM_CC_EnableChannel(Timer, channel);
|
LL_TIM_CC_EnableChannel(Timer, channel1);
|
||||||
|
LL_TIM_CC_EnableChannel(Timer, channel2);
|
||||||
|
|
||||||
LL_TIM_IC_InitTypeDef My_LL_Tim_IC_Init_Struct;
|
LL_TIM_IC_InitTypeDef My_LL_Tim_IC_Init_Struct;
|
||||||
|
|
||||||
|
//Configuration du channel1 (front montant, mappé sur TI1 = valeurs par défaut)
|
||||||
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
|
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
|
||||||
//Compléter ici?!...
|
LL_TIM_IC_Init(Timer,channel1,&My_LL_Tim_IC_Init_Struct);
|
||||||
|
|
||||||
LL_TIM_IC_Init(Timer,channel,&My_LL_Tim_IC_Init_Struct);
|
//Configuration du channel2 (front descendant, mappé sur TI1 = valeurs modifiées)
|
||||||
|
LL_TIM_IC_StructInit(&My_LL_Tim_IC_Init_Struct);
|
||||||
|
//Détection sur front descendant
|
||||||
|
My_LL_Tim_IC_Init_Struct.ICPolarity = LL_TIM_IC_POLARITY_FALLING;
|
||||||
|
//Mappage sur TI1
|
||||||
|
My_LL_Tim_IC_Init_Struct.ICActiveInput = LL_TIM_ACTIVEINPUT_INDIRECTTI;
|
||||||
|
LL_TIM_IC_Init(Timer,channel2,&My_LL_Tim_IC_Init_Struct);
|
||||||
|
|
||||||
|
//Definition du trigger
|
||||||
|
LL_TIM_SetTriggerInput(Timer, LL_TIM_TS_TI1FP1);
|
||||||
|
|
||||||
|
//Configure le mode esclave en mode RESET
|
||||||
|
LL_TIM_SetSlaveMode(Timer, LL_TIM_SLAVEMODE_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "stm32f1xx_ll_tim.h"
|
#include "stm32f1xx_ll_tim.h"
|
||||||
|
|
||||||
|
|
||||||
void MyPWM_Conf_Output(TIM_TypeDef * Timer);
|
void MyPWM_Conf_Output(TIM_TypeDef * Timer, int channel);
|
||||||
|
|
||||||
void MyPWM_Conf_Input(TIM_TypeDef * Timer);
|
void MyPWM_Conf_Input(TIM_TypeDef * Timer, int channel1, int channel2);
|
||||||
|
|
||||||
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage);
|
void MyPWM_Set_Impulse_Duration(TIM_TypeDef * Timer, int Percentage);
|
||||||
|
|
|
@ -32,7 +32,7 @@ void (*Ptr_ItFct_TIM4)(void);
|
||||||
* int Psc : valeur à placer dans PSC
|
* int Psc : valeur à placer dans PSC
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void MyTimer_Conf(TIM_TypeDef * Timer, int Period)
|
void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc)
|
||||||
{
|
{
|
||||||
LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
|
LL_TIM_InitTypeDef My_LL_Tim_Init_Struct;
|
||||||
|
|
||||||
|
@ -42,9 +42,6 @@ void MyTimer_Conf(TIM_TypeDef * Timer, int Period)
|
||||||
else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
|
else if (Timer==TIM3) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3);
|
||||||
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
|
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM4);
|
||||||
|
|
||||||
int Psc = (Period*72*1000000)/256 + 2;
|
|
||||||
int Arr = (Period*72*1000000)/Psc + 1;
|
|
||||||
|
|
||||||
// chargement structure Arr, Psc, Up Count
|
// chargement structure Arr, Psc, Up Count
|
||||||
My_LL_Tim_Init_Struct.Autoreload=Arr;
|
My_LL_Tim_Init_Struct.Autoreload=Arr;
|
||||||
My_LL_Tim_Init_Struct.Prescaler=Psc;
|
My_LL_Tim_Init_Struct.Prescaler=Psc;
|
||||||
|
|
|
@ -18,7 +18,7 @@ Driver pour Timer 1
|
||||||
* int Psc : valeur à placer dans PSC
|
* int Psc : valeur à placer dans PSC
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void MyTimer_Conf(TIM_TypeDef * Timer,int Period);
|
void MyTimer_Conf(TIM_TypeDef * Timer, int Arr, int Psc);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
21
Src/main.c
21
Src/main.c
|
@ -19,6 +19,8 @@
|
||||||
#include "stm32f1xx_ll_rcc.h" // utile dans la fonction SystemClock_Config
|
#include "stm32f1xx_ll_rcc.h" // utile dans la fonction SystemClock_Config
|
||||||
#include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config
|
#include "stm32f1xx_ll_utils.h" // utile dans la fonction SystemClock_Config
|
||||||
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
#include "stm32f1xx_ll_system.h" // utile dans la fonction SystemClock_Config
|
||||||
|
#include "stm32f1xx_ll_gpio.h"
|
||||||
|
#include "MyTimer.h"
|
||||||
#include "MyPWM.h"
|
#include "MyPWM.h"
|
||||||
|
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
|
@ -37,6 +39,25 @@ int main(void)
|
||||||
/* Configure the system clock to 72 MHz */
|
/* Configure the system clock to 72 MHz */
|
||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
|
|
||||||
|
MyTimer_Conf(TIM1,999, 719);
|
||||||
|
|
||||||
|
MyPWM_Conf_Output(TIM1, LL_TIM_CHANNEL_CH1);
|
||||||
|
|
||||||
|
MyPWM_Set_Impulse_Duration(TIM1, 25);
|
||||||
|
|
||||||
|
// LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
||||||
|
// GPIO_TypeDef * GPIO;
|
||||||
|
// LL_GPIO_InitTypeDef My_GPIO_Init_Struct;
|
||||||
|
// GPIO = GPIOA;
|
||||||
|
// My_GPIO_Init_Struct.Pin = LL_GPIO_PIN_8;
|
||||||
|
// My_GPIO_Init_Struct.Mode = LL_GPIO_MODE_OUTPUT;
|
||||||
|
// My_GPIO_Init_Struct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||||
|
// My_GPIO_Init_Struct.Speed = LL_GPIO_MODE_OUTPUT_10MHz;
|
||||||
|
// My_GPIO_Init_Struct.Pull = LL_GPIO_PULL_DOWN;
|
||||||
|
// LL_GPIO_Init(GPIO, &My_GPIO_Init_Struct);
|
||||||
|
|
||||||
|
MyTimer_Start(TIM1);
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue