File tree Expand file tree Collapse file tree 4 files changed +19
-20
lines changed
libraries/mbed/targets/hal/TARGET_STM Expand file tree Collapse file tree 4 files changed +19
-20
lines changed Original file line number Diff line number Diff line change 3737
3838static int us_ticker_inited = 0 ;
3939static volatile uint32_t SlaveCounter = 0 ;
40- static uint32_t oc_int_part = 0 ;
41- static uint16_t oc_rem_part = 0 ;
40+ static volatile uint32_t oc_int_part = 0 ;
41+ static volatile uint16_t oc_rem_part = 0 ;
4242
4343void set_compare (uint16_t count ) {
4444 // Set new output compare value
Original file line number Diff line number Diff line change 3737
3838static int us_ticker_inited = 0 ;
3939static volatile uint32_t SlaveCounter = 0 ;
40- static uint32_t oc_int_part = 0 ;
41- static uint16_t oc_rem_part = 0 ;
40+ static volatile uint32_t oc_int_part = 0 ;
41+ static volatile uint16_t oc_rem_part = 0 ;
4242
4343void set_compare (uint16_t count ) {
4444 // Set new output compare value
Original file line number Diff line number Diff line change @@ -40,8 +40,8 @@ static TIM_HandleTypeDef TimMasterHandle;
4040
4141static int us_ticker_inited = 0 ;
4242static volatile uint32_t SlaveCounter = 0 ;
43- static uint32_t oc_int_part = 0 ;
44- static uint16_t oc_rem_part = 0 ;
43+ static volatile uint32_t oc_int_part = 0 ;
44+ static volatile uint16_t oc_rem_part = 0 ;
4545
4646void set_compare (uint16_t count ) {
4747 // Set new output compare value
Original file line number Diff line number Diff line change 3636
3737static int us_ticker_inited = 0 ;
3838static volatile uint32_t SlaveCounter = 0 ;
39- static uint32_t oc_int_part = 0 ;
40- static uint16_t oc_rem_part = 0 ;
39+ static volatile uint32_t oc_int_part = 0 ;
40+ static volatile uint16_t oc_rem_part = 0 ;
4141
4242void set_compare (uint16_t count ) {
4343 // Set new output compare value
@@ -58,20 +58,19 @@ static void tim_update_oc_irq_handler(void) {
5858 // Output compare interrupt: used by interrupt system
5959 if (TIM_GetITStatus (TIM_MST , TIM_IT_CC1 ) == SET ) {
6060 TIM_ClearITPendingBit (TIM_MST , TIM_IT_CC1 );
61- }
62-
63- if (oc_rem_part > 0 ) {
64- set_compare (oc_rem_part ); // Finish the remaining time left
65- oc_rem_part = 0 ;
66- }
67- else {
68- if (oc_int_part > 0 ) {
69- set_compare (0xFFFF );
70- oc_rem_part = cval ; // To finish the counter loop the next time
71- oc_int_part -- ;
61+ if (oc_rem_part > 0 ) {
62+ set_compare (oc_rem_part ); // Finish the remaining time left
63+ oc_rem_part = 0 ;
7264 }
7365 else {
74- us_ticker_irq_handler ();
66+ if (oc_int_part > 0 ) {
67+ set_compare (0xFFFF );
68+ oc_rem_part = cval ; // To finish the counter loop the next time
69+ oc_int_part -- ;
70+ }
71+ else {
72+ us_ticker_irq_handler ();
73+ }
7574 }
7675 }
7776}
You can’t perform that action at this time.
0 commit comments