Skip to content

Commit 82d82d0

Browse files
committed
[NUCLEO_F070RB] 16-bit timer register update
This path fixes issue #816. Current value of TIM_MST->CNT is read in interrupt context only. This avoids master timer overflow without SlaveCounter update. Change-Id: Iaaf7b9eb33aa8d8992e9354ca5e21bf01ec2413d
1 parent e938780 commit 82d82d0

File tree

1 file changed

+3
-2
lines changed
  • hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F070RB

1 file changed

+3
-2
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F070RB/hal_tick.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ void set_compare(uint16_t count);
4343
extern volatile uint32_t SlaveCounter;
4444
extern volatile uint32_t oc_int_part;
4545
extern volatile uint16_t oc_rem_part;
46+
extern volatile uint16_t cnt_val;
4647

4748
// Used to increment the slave counter
4849
void timer_update_irq_handler(void)
@@ -59,7 +60,7 @@ void timer_update_irq_handler(void)
5960
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
6061
void timer_oc_irq_handler(void)
6162
{
62-
uint16_t cval = TIM_MST->CNT;
63+
cnt_val = TIM_MST->CNT;
6364
TimMasterHandle.Instance = TIM_MST;
6465

6566
// Channel 1 for mbed timeout
@@ -71,7 +72,7 @@ void timer_oc_irq_handler(void)
7172
} else {
7273
if (oc_int_part > 0) {
7374
set_compare(0xFFFF);
74-
oc_rem_part = cval; // To finish the counter loop the next time
75+
oc_rem_part = cnt_val; // To finish the counter loop the next time
7576
oc_int_part--;
7677
} else {
7778
us_ticker_irq_handler();

0 commit comments

Comments
 (0)