Hi there i m a student working on STM32F723 the first time, I encountered an register setting example as follows:
GPIOC->MODER |= ((2<<(6*2)) \ (2<<(7*2))); i konw its setting the GPIO register but whats the meaning of * and 2<< at the beginning sentence? and what does bit does it set?
GPIOC-> AFR |= ((8<<(6*4)) | (8<<(7*4))); whats the meaning of 8 and 4 means? and whats bits it set?
thanks in advance.
This is related to the syntax of the C language.
8 is a representation of 1000 binary. And << shifts the bits left. (6*4) = 24.
You will find the details in a good C course; knowledge of C is essential if you want to work with complex devices as STM32 microcontrollers.
The *2 is the bit width of the MODE option, the 6 is the pin number or index, the 2 is the MODE for the pin.
The code will be folded and optimized by the compiler, it's done verbosely so you can see how it was arrived at without some unexplained constant.
The AFR options are 4 bits wide taking a value between 0 and 15, determining what functional connection is mapped to a pin.
The 8 is AF8, the part Data Sheet/Manual should have a list of tables showing what peripheral maps at that slot.
There's a lot of junk code written by ..er... budding electronic engineers. If you don't understand it and think it could be clearer/laid out better, fix it (but test your understanding first!). Don't skip your C lectures ))