cancel
Showing results for 
Search instead for 
Did you mean: 

Dubious update of TIM8_DMAR

HermannKleier
Associate II
Posted on November 26, 2016 at 15:52

When debugging an application I wondered about a strange value in

TIM8_DMAR

that I had not written there intentionally. In the end it all boiled down to an invocation of

LL_TIM_SetCounterMode (TIM8, LL_TIM_COUNTERMODE_DOWN)

:


822 LL_TIM_SetCounterMode (TIM8, LL_TIM_COUNTERMODE_DOWN);

(gdb) s

LL_TIM_SetCounterMode (TIMx=0x40013400, CounterMode=16) at /home/h/STM32Cube/Repository/STM32Cube_FW_L4_V1.5.2/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_tim.h:1467

1467 MODIFY_REG(TIMx->CR1, TIM_CR1_DIR | TIM_CR1_CMS, CounterMode);

(gdb) p/x &TIMx->CR1

$27 = 0x40013400

(gdb) p/x TIMx->CR1

$28 = 0x0

(gdb) p/x &TIMx->DMAR

$29 = 0x4001344c

(gdb) p/x TIMx->DMAR

$30 = 0x0

(gdb) s

1468 }

(gdb) p/x TIMx->CR1

$31 = 0x10

(gdb) p/x TIMx->DMAR

$32 = 0x10

(gdb)

After stepping into (line 2) I checked addresses and contents of the peripheral registers

TIM8_CR1

and

TIM8_DMAR

(lines 5 to 12). Everything behaved as expected. No bad defined structures and the contents were still at their reset values. However, the next step (line 13) changed

TIM8_DMAR

to the same value as

TIM8_CR1

(line 18). I checked the definition of

MODIFY_REG

, but it was reasonable:

1.
#define WRITE_REG(REG, VAL) ((REG) = (VAL))
2.
#define READ_REG(REG) ((REG))
3.
#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))

What is happening here? #stm32l476rgt6u
0 REPLIES 0