Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspicious TIM1 interrupt configuration #52

Open
wuwbobo2021 opened this issue Jan 8, 2025 · 0 comments
Open

Suspicious TIM1 interrupt configuration #52

wuwbobo2021 opened this issue Jan 8, 2025 · 0 comments

Comments

@wuwbobo2021
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant