2017-03-08 02:33 AM
hi
first i look here
but there is no usart driver.
this is my schematic
according to schematic i use pa2 and pa3 as usart.
please tell me if there is any library to init usart and use it.
if there is not .
datasheet give me something but its hard to understand . what to do?
first
Alternate function selection
/* This sequence select AF2 for GPIOA5, 8 and 9. This can be easily adapted
with another port by changing all GPIOA references by another GPIO port,
and the alternate function number can be changed by replacing 0x02 for
each pin by the targeted alternate function in the 2 last code lines. */
/* (1) Enable the peripheral clock of GPIOA */
/* (2) Select alternate function mode on GPIOA pin 5, 8 and 9 */
/* (3) Select AF2 on PA5 in AFRL for TIM2_CH1 */
/* (4) Select AF2 on PA8 and PA9 in AFRH for TIM1_CH1 and TIM1_CH2 */
RCC->AHBENR |= RCC_AHBENR_GPIOAEN; /* (1) */
GPIOA->MODER = (GPIOA->MODER & ~(GPIO_MODER_MODER5 | GPIO_MODER_MODER8
| GPIO_MODER_MODER9)) | GPIO_MODER_MODER5_1
| GPIO_MODER_MODER8_1 | GPIO_MODER_MODER9_1; /* (2) */
GPIOA->AFR[0] |= 0x02 << (5 * 4); /* (3) */
GPIOA->AFR[1] |= 0x02 | (0x02 << ((9 - 8) * 4)); /* (4) */�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
but line 3 and line 4 is so hard to get . why 5*4 why ((9-8)*4)) :!
please somebody help me
2017-03-08 05:10 AM
Cross posting
https://community.st.com/0D50X00009XkYZqSAN
I'd use the STM32F0 SPL (Standard Peripheral Library), but that's me
http://www.st.com/en/embedded-software/stsw-stm32html