2015-06-24 10:58 PM
dear all, i am bit confused in understanding the register handling of stm32 controller using c language. i am using keil compiler. i like to read, write register and set or clear single bit in the register. i want to write programs from scratch and dont want to use HAL library. i have to add just a header file like the one attached in the post and want to read and write register in bit and byte wise.
please give examples for the same.thanks in advance #stm32 #c-programming2015-06-24 11:23 PM
You could still review how the SPL and HAL are coded, it would provide you with plenty of examples.
The registers are described in the Reference ManualThe peripheral registers reside within the processors normal address space, and read/write in a similar manner to RAMUSART1
->
CR1=
USART_CR1_UE|
USART_CR1_TE|
USART_CR1_RE;
2015-06-25 12:37 AM
thanks clive. if i want read adc data register to a variable how can i do it.
for extemp = ADC1->DR; is it rightand to clear a bitUSART1
->
CR1=
!USART_CR1_UE; is right?2015-06-25 05:51 AM
In C, bit-wise operations are done like this
USART1->CR1 &= ~USART_CR1_UE; // Clear Uart Enable