Skip to content

Commit e938780

Browse files
kulaarafBartSX
authored andcommitted
[NUCLEO_F103RB] 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: Ie7a9bfce76990f85caa84264450d053604af33e5
1 parent 07b841b commit e938780

File tree

1 file changed

+3
-2
lines changed
  • hal/targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_DISCO_F100RB

1 file changed

+3
-2
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32F1/TARGET_DISCO_F100RB/hal_tick.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ 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
void timer_irq_handler(void) {
48-
uint16_t cval = TIM_MST->CNT;
49+
cnt_val= TIM_MST->CNT;
4950

5051
TimMasterHandle.Instance = TIM_MST;
5152

@@ -64,7 +65,7 @@ void timer_irq_handler(void) {
6465
} else {
6566
if (oc_int_part > 0) {
6667
set_compare(0xFFFF);
67-
oc_rem_part = cval; // To finish the counter loop the next time
68+
oc_rem_part = cnt_val; // To finish the counter loop the next time
6869
oc_int_part--;
6970
} else {
7071
us_ticker_irq_handler();

0 commit comments

Comments
 (0)