Skip to main content
qqqwa
Associate
September 16, 2019
Question

STM32G0CUBE DMA HAL DRIVER FILE PROBLEM

  • September 16, 2019
  • 2 replies
  • 797 views

In 'STM32G0xx_HAL_Driver\Src\stm32g0xx_hal_dma.c', Line 1032, 'hdma->DMAmuxChannelStatusMask = 1UL << (channel_number & 0x1cU)' , why the channel number is anded with 0x1C? shouldn't that be anded with 0x7f?

This topic has been closed for replies.

2 replies

After Forever
Senior III
September 16, 2019

> shouldn't that be anded with 0x7f?

Even without looking up the HAL code (more than to know that DMAmuxChannelStatusMask is uint32_t) or register definitions in RM, I guess no: why would you want to shift to left the "1" in a 32-bit value by 127 bits? Shifting it up to 28 bits seems more reasonable (:

qqqwa
qqqwaAuthor
Associate
September 16, 2019

I mean that Channel number is from 0 to 6. ​the bits of the flag registers are also 0 to 6 respectively. the (channel_number & 0x1cU) has already change the primary position that the data should be shifted.

In fact, I think the whole sentence could be "'hdma->DMAmuxChannelStatusMask = 1UL << (channel_number )".