Skip to content
Snippets Groups Projects
Commit 17bbc4e0 authored by Sergi Hernandez's avatar Sergi Hernandez
Browse files

Solved a bug in the schdulers when the timer has 32 bits intstead of 16.

parent 6e3070dc
No related branches found
No related tags found
No related merge requests found
...@@ -80,7 +80,8 @@ void darwin_sch_set_pulse(unsigned short int channel_id,unsigned short int pulse ...@@ -80,7 +80,8 @@ void darwin_sch_set_pulse(unsigned short int channel_id,unsigned short int pulse
else else
{ {
capture = HAL_TIM_ReadCapturedValue(&darwin_sch_timer_handle, channel_id); capture = HAL_TIM_ReadCapturedValue(&darwin_sch_timer_handle, channel_id);
__HAL_TIM_SetCompare(&darwin_sch_timer_handle,channel_id, capture+pulse); capture+=pulse;
__HAL_TIM_SetCompare(&darwin_sch_timer_handle,channel_id, capture);
} }
} }
......
...@@ -80,7 +80,8 @@ void darwin_sch2_set_pulse(unsigned short int channel_id,unsigned short int puls ...@@ -80,7 +80,8 @@ void darwin_sch2_set_pulse(unsigned short int channel_id,unsigned short int puls
else else
{ {
capture = HAL_TIM_ReadCapturedValue(&darwin_sch2_timer_handle, channel_id); capture = HAL_TIM_ReadCapturedValue(&darwin_sch2_timer_handle, channel_id);
__HAL_TIM_SetCompare(&darwin_sch2_timer_handle,channel_id, capture+pulse); capture+=pulse;
__HAL_TIM_SetCompare(&darwin_sch2_timer_handle,channel_id, capture);
} }
} }
...@@ -93,9 +94,9 @@ TScheduler *darwin_sch2_init(void) ...@@ -93,9 +94,9 @@ TScheduler *darwin_sch2_init(void)
__HAL_RCC_TIM2_CLK_ENABLE(); __HAL_RCC_TIM2_CLK_ENABLE();
darwin_sch2_timer_handle.Instance = TIM2; darwin_sch2_timer_handle.Instance = TIM2;
darwin_sch2_timer_handle.Init.Prescaler = 168; darwin_sch2_timer_handle.Init.Prescaler = 84;
darwin_sch2_timer_handle.Init.CounterMode = TIM_COUNTERMODE_UP; darwin_sch2_timer_handle.Init.CounterMode = TIM_COUNTERMODE_UP;
darwin_sch2_timer_handle.Init.Period = 0xFFFF; darwin_sch2_timer_handle.Init.Period = 0x0000FFFF;
darwin_sch2_timer_handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; darwin_sch2_timer_handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
HAL_TIM_Base_Init(&darwin_sch2_timer_handle); HAL_TIM_Base_Init(&darwin_sch2_timer_handle);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment