Skip to content

Suspicious TIM1 interrupt configuration #52

@wuwbobo2021

Description

@wuwbobo2021

This issue can be checked and closed soon. Please check this line in main.c initialization code:

	// Start Timer 1
	if(HAL_TIM_Base_Start_IT(&htim1) != HAL_OK)

This enables TIM_IT_UPDATE for TIM1, however, HAL_TIM_PeriodElapsedCallback does nothing for TIM1. I changed it to if(HAL_TIM_Base_Start(&htim1) != HAL_OK) and it still works. I think it will save some CPU time.

With the BKL Brake pin (PA11, TIM1_CH4), there's

	HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_4);

I changed it to HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4); and it seems like it works. Commenting out it will disable the motor, probably because its capture/compare register is used in dyn_adc_state. In the mean time, its corresponding pin (Brake_Pin) state configured and read as a GPIO input. Maybe they are unrelated...

		//sConfigOC.OCMode = TIM_OCMODE_ACTIVE; // war hier ein Bock?!
		sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
		if (HAL_TIM_OC_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)

What does "war hier ein Bock?!" mean? I guess this line should be removed... Having problem with the translation service...

HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_4) enables TIM_IT_CC4 for TIM4; if this flag is set, the HAL IRQ handler will call HAL_TIM_IC_CaptureCallback under IC mode, or HAL_TIM_OC_DelayElapsedCallback/HAL_TIM_PWM_PulseFinishedCallback under OC mode. I think it's configured in OC mode here as an internal comparer... so HAL_TIM_IC_CaptureCallback is defined just for TIM2 and the hall sensor, and the other 2 functions aren't defind.

PS: PB12 TIM1_BKIN in the pinout diagram seems to have no corresponding function (unconfigured).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions