2009-07-04 02:21 AM
USART1 = dead!
2011-05-17 04:16 AM
Quote:
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; Try changing the above line to GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; Remember that peripheral outputs only connect to port pins when they're configured as an ''alternate function'' ;) Peripheral inputs always connect. You'll also need to enable the alternate function clock. RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);2011-05-17 04:16 AM
Hi everybody!
Im wondering if someone got a clue what the problem could be, the Usart1 doesnt work at all. Ive tried everything! Im using Crossworks 1.7 with STM32F103CBT6. I get no signal mesured with a oscillscope. Clock are set but nothing happens! //Code RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB | RCC_APB2Periph_USART1, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); USART_InitTypeDef USART_InitStructure; USART_InitStructure.USART_BaudRate = 57600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); /* Enable USART1 */ USART_Cmd(USART1, ENABLE); While(1){ void SerialPutChar('a') { USART_SendData(USART1, c); while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); } } Regards Niklas :o2011-05-17 04:16 AM
Hi swhite!
thank you so much! This line made my day GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; !! Ive been trying for a week now. Thank you again! Regards