2022-05-30 04:13 AM
Hello
I am not very familiar with the Low-level stm32F register,
I have a question about the definition of each register in the TIM_TypeDef
I want to have a separate access to each bit, It is possible?
I the stm32F429xx.h I have this:
typedef struct
{
__IO uint32_t CR1; /*!< TIM control register 1, Address offset: 0x00 */
__IO uint32_t CR2; /*!< TIM control register 2, Address offset: 0x04 */
__IO uint32_t SMCR; /*!< TIM slave mode control register, Address offset: 0x08 */
__IO uint32_t DIER; /*!< TIM DMA/interrupt enable register, Address offset: 0x0C */
__IO uint32_t SR; /*!< TIM status register, Address offset: 0x10 */
__IO uint32_t EGR; /*!< TIM event generation register, Address offset: 0x14 */
__IO uint32_t CCMR1; /*!< TIM capture/compare mode register 1, Address offset: 0x18 */
__IO uint32_t CCMR2; /*!< TIM capture/compare mode register 2, Address offset: 0x1C */
__IO uint32_t CCER; /*!< TIM capture/compare enable register, Address offset: 0x20 */
__IO uint32_t CNT; /*!< TIM counter register, Address offset: 0x24 */
__IO uint32_t PSC; /*!< TIM prescaler, Address offset: 0x28 */
__IO uint32_t ARR; /*!< TIM auto-reload register, Address offset: 0x2C */
__IO uint32_t RCR; /*!< TIM repetition counter register, Address offset: 0x30 */
__IO uint32_t CCR1; /*!< TIM capture/compare register 1, Address offset: 0x34 */
__IO uint32_t CCR2; /*!< TIM capture/compare register 2, Address offset: 0x38 */
__IO uint32_t CCR3; /*!< TIM capture/compare register 3, Address offset: 0x3C */
__IO uint32_t CCR4; /*!< TIM capture/compare register 4, Address offset: 0x40 */
__IO uint32_t BDTR; /*!< TIM break and dead-time register, Address offset: 0x44 */
__IO uint32_t DCR; /*!< TIM DMA control register, Address offset: 0x48 */
__IO uint32_t DMAR; /*!< TIM DMA address for full transfer, Address offset: 0x4C */
__IO uint32_t OR; /*!< TIM option register, Address offset: 0x50 */
} TIM_TypeDef;
I want do something like this:
TIM2.CR1.bit.CEN = 0;
Is it possible, if not could help me to use the masks configured bit by bit?
Thank you,
2022-05-30 04:30 AM
Are you asking whether STM32F4 supports so called bit-bands as in some other MCUs? No it does not.
Just read the whole register and apply the usual C bit operations.
Also, someone posted here a nice C++ register class which allows bit-level manipulation.
2022-05-30 05:38 AM
> Are you asking whether STM32F4 supports so called bit-bands as in some other MCUs? No it does not.
This is not true.
However, I don't recommend bit-band access on anything but pure setup registers.
Nonetheless, OP probably asked about predefined bitfields for the registers - there the answer is, no, accept what's there, learn to live with the usual C bit operations as Pavel recommended above.
JW