timer based ADC triggering

calib-gui
Ondřej Hruška 2 years ago
parent bff7f6e916
commit 091d6c5648
  1. 38
      BluepillTrouba.ioc
  2. 4
      Core/Inc/main.h
  3. 1
      Core/Inc/stm32f1xx_it.h
  4. 1
      Core/Inc/tim.h
  5. 10
      Core/Src/adc.c
  6. 2
      Core/Src/app_heater.c
  7. 16
      Core/Src/app_temp.c
  8. 2
      Core/Src/freertos.c
  9. 1
      Core/Src/main.c
  10. 21
      Core/Src/stm32f1xx_it.c
  11. 52
      Core/Src/tim.c
  12. 1
      Core/Src/usart.c
  13. 2
      Makefile
  14. 13
      Middlewares/Third_Party/FreeRTOS/Source/tasks.c

@ -3,8 +3,9 @@ ADC1.Channel-0\#ChannelRegularConversion=ADC_CHANNEL_0
ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_1 ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_1
ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR ADC1.Channel-2\#ChannelRegularConversion=ADC_CHANNEL_TEMPSENSOR
ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_VREFINT ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_VREFINT
ADC1.ContinuousConvMode=ENABLE ADC1.ContinuousConvMode=DISABLE
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,NbrOfConversion ADC1.ExternalTrigConv=ADC_EXTERNALTRIGCONV_T1_CC1
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,master,ContinuousConvMode,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,NbrOfConversion,ExternalTrigConv
ADC1.NbrOfConversion=4 ADC1.NbrOfConversion=4
ADC1.NbrOfConversionFlag=1 ADC1.NbrOfConversionFlag=1
ADC1.Rank-0\#ChannelRegularConversion=1 ADC1.Rank-0\#ChannelRegularConversion=1
@ -49,17 +50,18 @@ Mcu.CPN=STM32F103C8T6
Mcu.Family=STM32F1 Mcu.Family=STM32F1
Mcu.IP0=ADC1 Mcu.IP0=ADC1
Mcu.IP1=DMA Mcu.IP1=DMA
Mcu.IP10=TIM4 Mcu.IP10=TIM3
Mcu.IP11=USART1 Mcu.IP11=TIM4
Mcu.IP12=USART1
Mcu.IP2=FREERTOS Mcu.IP2=FREERTOS
Mcu.IP3=IWDG Mcu.IP3=IWDG
Mcu.IP4=NVIC Mcu.IP4=NVIC
Mcu.IP5=RCC Mcu.IP5=RCC
Mcu.IP6=SPI2 Mcu.IP6=SPI2
Mcu.IP7=SYS Mcu.IP7=SYS
Mcu.IP8=TIM2 Mcu.IP8=TIM1
Mcu.IP9=TIM3 Mcu.IP9=TIM2
Mcu.IPNb=12 Mcu.IPNb=13
Mcu.Name=STM32F103C(8-B)Tx Mcu.Name=STM32F103C(8-B)Tx
Mcu.Package=LQFP48 Mcu.Package=LQFP48
Mcu.Pin0=PC13-TAMPER-RTC Mcu.Pin0=PC13-TAMPER-RTC
@ -77,8 +79,10 @@ Mcu.Pin19=VP_FREERTOS_VS_CMSIS_V2
Mcu.Pin2=PA1 Mcu.Pin2=PA1
Mcu.Pin20=VP_IWDG_VS_IWDG Mcu.Pin20=VP_IWDG_VS_IWDG
Mcu.Pin21=VP_SYS_VS_Systick Mcu.Pin21=VP_SYS_VS_Systick
Mcu.Pin22=VP_TIM2_VS_ClockSourceINT Mcu.Pin22=VP_TIM1_VS_ClockSourceINT
Mcu.Pin23=VP_TIM3_VS_ClockSourceINT Mcu.Pin23=VP_TIM1_VS_no_output1
Mcu.Pin24=VP_TIM2_VS_ClockSourceINT
Mcu.Pin25=VP_TIM3_VS_ClockSourceINT
Mcu.Pin3=PA6 Mcu.Pin3=PA6
Mcu.Pin4=PB0 Mcu.Pin4=PB0
Mcu.Pin5=PB1 Mcu.Pin5=PB1
@ -86,13 +90,12 @@ Mcu.Pin6=PB10
Mcu.Pin7=PB13 Mcu.Pin7=PB13
Mcu.Pin8=PB15 Mcu.Pin8=PB15
Mcu.Pin9=PA9 Mcu.Pin9=PA9
Mcu.PinsNb=24 Mcu.PinsNb=26
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F103C8Tx Mcu.UserName=STM32F103C8Tx
MxCube.Version=6.5.0 MxCube.Version=6.5.0
MxDb.Version=DB.6.0.50 MxDb.Version=DB.6.0.50
NVIC.ADC1_2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true
NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true
@ -109,8 +112,6 @@ NVIC.SavedSystickIrqHandlerGenerated=true
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true\:true NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true\:true
NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true NVIC.TIM4_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:true
PA0-WKUP.GPIOParameters=GPIO_Label
PA0-WKUP.GPIO_Label=ADC_PT100
PA0-WKUP.Signal=ADCx_IN0 PA0-WKUP.Signal=ADCx_IN0
PA1.GPIOParameters=GPIO_Label PA1.GPIOParameters=GPIO_Label
PA1.GPIO_Label=ADC_SENSR PA1.GPIO_Label=ADC_SENSR
@ -194,7 +195,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Makefile ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_IWDG_Init-IWDG-false-LL-true,4-MX_USART1_UART_Init-USART1-false-LL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_DMA_Init-DMA-false-LL-true,7-MX_TIM4_Init-TIM4-false-LL-true,8-MX_TIM2_Init-TIM2-false-LL-true,9-MX_TIM3_Init-TIM3-false-LL-true,10-MX_SPI2_Init-SPI2-false-LL-true ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_IWDG_Init-IWDG-false-LL-true,4-MX_USART1_UART_Init-USART1-false-LL-true,5-MX_ADC1_Init-ADC1-false-LL-true,6-MX_DMA_Init-DMA-false-LL-true,7-MX_TIM4_Init-TIM4-false-LL-true,8-MX_TIM2_Init-TIM2-false-LL-true,9-MX_TIM3_Init-TIM3-false-LL-true,10-MX_SPI2_Init-SPI2-false-LL-true,11-MX_TIM1_Init-TIM1-false-LL-true
RCC.ADCFreqValue=8000000 RCC.ADCFreqValue=8000000
RCC.ADCPresc=RCC_ADCPCLK2_DIV8 RCC.ADCPresc=RCC_ADCPCLK2_DIV8
RCC.AHBFreq_Value=64000000 RCC.AHBFreq_Value=64000000
@ -236,6 +237,11 @@ SPI2.Direction=SPI_DIRECTION_2LINES
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
SPI2.Mode=SPI_MODE_MASTER SPI2.Mode=SPI_MODE_MASTER
SPI2.VirtualType=VM_MASTER SPI2.VirtualType=VM_MASTER
TIM1.Channel-PWM\ Generation1\ No\ Output=TIM_CHANNEL_1
TIM1.IPParameters=Prescaler,Period,TIM_MasterOutputTrigger,Channel-PWM Generation1 No Output
TIM1.Period=100
TIM1.Prescaler=64000
TIM1.TIM_MasterOutputTrigger=TIM_TRGO_OC1REF
TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1 TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM2.IPParameters=Channel-PWM Generation1 CH1,Prescaler TIM2.IPParameters=Channel-PWM Generation1 CH1,Prescaler
TIM2.Prescaler=2 TIM2.Prescaler=2
@ -260,6 +266,10 @@ VP_IWDG_VS_IWDG.Mode=IWDG_Activate
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
VP_SYS_VS_Systick.Mode=SysTick VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM1_VS_ClockSourceINT.Mode=Internal
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
VP_TIM1_VS_no_output1.Mode=PWM Generation1 No Output
VP_TIM1_VS_no_output1.Signal=TIM1_VS_no_output1
VP_TIM2_VS_ClockSourceINT.Mode=Internal VP_TIM2_VS_ClockSourceINT.Mode=Internal
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
VP_TIM3_VS_ClockSourceINT.Mode=Internal VP_TIM3_VS_ClockSourceINT.Mode=Internal

@ -50,6 +50,8 @@ extern "C" {
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#define __weak __attribute__((weak))
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
@ -77,8 +79,6 @@ void Error_Handler(void);
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/
#define LED_Pin LL_GPIO_PIN_13 #define LED_Pin LL_GPIO_PIN_13
#define LED_GPIO_Port GPIOC #define LED_GPIO_Port GPIOC
#define ADC_PT100_Pin LL_GPIO_PIN_0
#define ADC_PT100_GPIO_Port GPIOA
#define ADC_SENSR_Pin LL_GPIO_PIN_1 #define ADC_SENSR_Pin LL_GPIO_PIN_1
#define ADC_SENSR_GPIO_Port GPIOA #define ADC_SENSR_GPIO_Port GPIOA
#define OLED_CS_Pin LL_GPIO_PIN_0 #define OLED_CS_Pin LL_GPIO_PIN_0

@ -54,7 +54,6 @@ void UsageFault_Handler(void);
void DebugMon_Handler(void); void DebugMon_Handler(void);
void SysTick_Handler(void); void SysTick_Handler(void);
void DMA1_Channel1_IRQHandler(void); void DMA1_Channel1_IRQHandler(void);
void ADC1_2_IRQHandler(void);
void TIM4_IRQHandler(void); void TIM4_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */

@ -36,6 +36,7 @@ extern "C" {
/* USER CODE END Private defines */ /* USER CODE END Private defines */
void MX_TIM1_Init(void);
void MX_TIM2_Init(void); void MX_TIM2_Init(void);
void MX_TIM3_Init(void); void MX_TIM3_Init(void);
void MX_TIM4_Init(void); void MX_TIM4_Init(void);

@ -46,7 +46,7 @@ void MX_ADC1_Init(void)
PA0-WKUP ------> ADC1_IN0 PA0-WKUP ------> ADC1_IN0
PA1 ------> ADC1_IN1 PA1 ------> ADC1_IN1
*/ */
GPIO_InitStruct.Pin = ADC_PT100_Pin|ADC_SENSR_Pin; GPIO_InitStruct.Pin = LL_GPIO_PIN_0|ADC_SENSR_Pin;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG;
LL_GPIO_Init(GPIOA, &GPIO_InitStruct); LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
@ -67,10 +67,6 @@ void MX_ADC1_Init(void)
LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD); LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_HALFWORD);
/* ADC1 interrupt Init */
NVIC_SetPriority(ADC1_2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),5, 0));
NVIC_EnableIRQ(ADC1_2_IRQn);
/* USER CODE BEGIN ADC1_Init 1 */ /* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */ /* USER CODE END ADC1_Init 1 */
@ -82,10 +78,10 @@ void MX_ADC1_Init(void)
LL_ADC_Init(ADC1, &ADC_InitStruct); LL_ADC_Init(ADC1, &ADC_InitStruct);
ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT; ADC_CommonInitStruct.Multimode = LL_ADC_MULTI_INDEPENDENT;
LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct); LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct);
ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_EXT_TIM1_CH1;
ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS; ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS;
ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED;
LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct);

@ -109,6 +109,6 @@ void app_task_heater(void *argument)
// TODO notify UI thread of the new temperature and heating percent // TODO notify UI thread of the new temperature and heating percent
vTaskDelayUntil(&wake_time, pdMS_TO_TICKS(500)); vTaskDelayUntil(&wake_time, pdMS_TO_TICKS(100));
} }
} }

@ -16,8 +16,8 @@ static volatile uint16_t adc_values[4];
const float V_REFINT = 1.23f; const float V_REFINT = 1.23f;
#define AVERAGEBUF_DEPTH 16 #define AVERAGEBUF_DEPTH 8
#define OVENTEMP_HISTORY_DEPTH 10 #define OVENTEMP_HISTORY_DEPTH 5
static struct App { static struct App {
float oven_temp; float oven_temp;
@ -156,7 +156,14 @@ void app_analog_init()
LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_1); LL_DMA_EnableIT_TC(DMA1, LL_DMA_CHANNEL_1);
LL_ADC_REG_StartConversionExtTrig(ADC_TEMP, LL_ADC_REG_TRIG_EXT_RISING); LL_ADC_REG_StartConversionExtTrig(ADC_TEMP, LL_ADC_REG_TRIG_EXT_RISING);
LL_ADC_REG_StartConversionSWStart(ADC_TEMP); // LL_ADC_REG_StartConversionSWStart(ADC_TEMP);
LL_TIM_SetTriggerOutput(TIM1, LL_TIM_TRGO_CC1IF);
LL_TIM_CC_EnableChannel(TIM1, LL_TIM_CHANNEL_CH1);
LL_TIM_OC_SetCompareCH1(TIM1, 10);
LL_TIM_SetAutoReload(TIM1, 20);
LL_TIM_EnableAllOutputs(TIM1);
LL_TIM_EnableCounter(TIM1);
} }
static float val_to_c(float val) static float val_to_c(float val)
@ -241,7 +248,8 @@ float app_temp_read_soc()
void app_temp_adc_eos() void app_temp_adc_eos()
{ {
PUTCHAR('a'); //PUTCHAR('a');
// notify // notify
memcpy((void *) &s_analog.adc_averagebuf[s_analog.averagebuf_ptr * 4], (const void *) adc_values, 4 * sizeof(uint16_t)); memcpy((void *) &s_analog.adc_averagebuf[s_analog.averagebuf_ptr * 4], (const void *) adc_values, 4 * sizeof(uint16_t));
s_analog.averagebuf_ptr = (s_analog.averagebuf_ptr + 1) % AVERAGEBUF_DEPTH; s_analog.averagebuf_ptr = (s_analog.averagebuf_ptr + 1) % AVERAGEBUF_DEPTH;

@ -223,7 +223,7 @@ void MX_FREERTOS_Init(void) {
* @retval None * @retval None
*/ */
/* USER CODE END Header_app_task_main */ /* USER CODE END Header_app_task_main */
__attribute__((weak)) void app_task_main(void *argument) __weak void app_task_main(void *argument)
{ {
/* USER CODE BEGIN app_task_main */ /* USER CODE BEGIN app_task_main */
/* Infinite loop */ /* Infinite loop */

@ -118,6 +118,7 @@ int main(void)
MX_TIM2_Init(); MX_TIM2_Init();
MX_TIM3_Init(); MX_TIM3_Init();
MX_SPI2_Init(); MX_SPI2_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
PUTS("Start.\r\n"); PUTS("Start.\r\n");

@ -206,27 +206,6 @@ void DMA1_Channel1_IRQHandler(void)
/* USER CODE END DMA1_Channel1_IRQn 1 */ /* USER CODE END DMA1_Channel1_IRQn 1 */
} }
/**
* @brief This function handles ADC1 and ADC2 global interrupts.
*/
void ADC1_2_IRQHandler(void)
{
/* USER CODE BEGIN ADC1_2_IRQn 0 */
// app_temp_adc_eos();
// if (LL_ADC_IsActiveFlag_EOS(ADC_TEMP)) {
// LL_ADC_ClearFlag_EOS(ADC_TEMP);
// app_temp_adc_eos();
// }
/* USER CODE END ADC1_2_IRQn 0 */
/* USER CODE BEGIN ADC1_2_IRQn 1 */
/* USER CODE END ADC1_2_IRQn 1 */
}
/** /**
* @brief This function handles TIM4 global interrupt. * @brief This function handles TIM4 global interrupt.
*/ */

@ -24,6 +24,58 @@
/* USER CODE END 0 */ /* USER CODE END 0 */
/* TIM1 init function */
void MX_TIM1_Init(void)
{
/* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */
LL_TIM_InitTypeDef TIM_InitStruct = {0};
LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0};
LL_TIM_BDTR_InitTypeDef TIM_BDTRInitStruct = {0};
/* Peripheral clock enable */
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1);
/* USER CODE BEGIN TIM1_Init 1 */
/* USER CODE END TIM1_Init 1 */
TIM_InitStruct.Prescaler = 64000;
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
TIM_InitStruct.Autoreload = 100;
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1;
TIM_InitStruct.RepetitionCounter = 0;
LL_TIM_Init(TIM1, &TIM_InitStruct);
LL_TIM_DisableARRPreload(TIM1);
LL_TIM_SetClockSource(TIM1, LL_TIM_CLOCKSOURCE_INTERNAL);
LL_TIM_OC_EnablePreload(TIM1, LL_TIM_CHANNEL_CH1);
TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1;
TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE;
TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE;
TIM_OC_InitStruct.CompareValue = 0;
TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH;
TIM_OC_InitStruct.OCNPolarity = LL_TIM_OCPOLARITY_HIGH;
TIM_OC_InitStruct.OCIdleState = LL_TIM_OCIDLESTATE_LOW;
TIM_OC_InitStruct.OCNIdleState = LL_TIM_OCIDLESTATE_LOW;
LL_TIM_OC_Init(TIM1, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct);
LL_TIM_OC_DisableFast(TIM1, LL_TIM_CHANNEL_CH1);
LL_TIM_SetTriggerOutput(TIM1, LL_TIM_TRGO_OC1REF);
LL_TIM_DisableMasterSlaveMode(TIM1);
TIM_BDTRInitStruct.OSSRState = LL_TIM_OSSR_DISABLE;
TIM_BDTRInitStruct.OSSIState = LL_TIM_OSSI_DISABLE;
TIM_BDTRInitStruct.LockLevel = LL_TIM_LOCKLEVEL_OFF;
TIM_BDTRInitStruct.DeadTime = 0;
TIM_BDTRInitStruct.BreakState = LL_TIM_BREAK_DISABLE;
TIM_BDTRInitStruct.BreakPolarity = LL_TIM_BREAK_POLARITY_HIGH;
TIM_BDTRInitStruct.AutomaticOutput = LL_TIM_AUTOMATICOUTPUT_DISABLE;
LL_TIM_BDTR_Init(TIM1, &TIM_BDTRInitStruct);
/* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */
}
/* TIM2 init function */ /* TIM2 init function */
void MX_TIM2_Init(void) void MX_TIM2_Init(void)
{ {

@ -73,6 +73,5 @@ void MX_USART1_UART_Init(void)
} }
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */

@ -1,5 +1,5 @@
########################################################################################################################## ##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Sun Mar 12 14:42:27 CET 2023] # File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Sun Mar 12 21:45:54 CET 2023]
########################################################################################################################## ##########################################################################################################################
# ------------------------------------------------ # ------------------------------------------------

@ -53,8 +53,7 @@ functions but without including stdio.h here. */
to generate human readable text from the raw data generated by the to generate human readable text from the raw data generated by the
uxTaskGetSystemState() function. Note the formatting functions are provided uxTaskGetSystemState() function. Note the formatting functions are provided
for convenience only, and are NOT considered part of the kernel. */ for convenience only, and are NOT considered part of the kernel. */
//#include <stdio.h> #include <stdio.h>
#include "snprintf.h"
#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */ #endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */
#if( configUSE_PREEMPTION == 0 ) #if( configUSE_PREEMPTION == 0 )
@ -4230,7 +4229,7 @@ TCB_t *pxTCB;
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );
/* Write the rest of the string. */ /* Write the rest of the string. */
SPRINTF( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );
pcWriteBuffer += strlen( pcWriteBuffer ); pcWriteBuffer += strlen( pcWriteBuffer );
} }
@ -4326,13 +4325,13 @@ TCB_t *pxTCB;
{ {
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED #ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{ {
SPRINTF( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );
} }
#else #else
{ {
/* sizeof( int ) == sizeof( long ) so a smaller /* sizeof( int ) == sizeof( long ) so a smaller
printf() library can be used. */ printf() library can be used. */
SPRINTF( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );
} }
#endif #endif
} }
@ -4342,13 +4341,13 @@ TCB_t *pxTCB;
consumed less than 1% of the total run time. */ consumed less than 1% of the total run time. */
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED #ifdef portLU_PRINTF_SPECIFIER_REQUIRED
{ {
SPRINTF( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter ); sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter );
} }
#else #else
{ {
/* sizeof( int ) == sizeof( long ) so a smaller /* sizeof( int ) == sizeof( long ) so a smaller
printf() library can be used. */ printf() library can be used. */
SPRINTF( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );
} }
#endif #endif
} }

Loading…
Cancel
Save