Question
stm32f051c8t6 NVIC and USART Problem
Posted on September 23, 2013 at 11:33
Hi,
I configured USART1 in stm32f051c8t6 but when i run the code on my h/w it goes hang. I dont where it is hanging. whether because of NVIC OR USART. But according to me it hang in NVIC because everything run ok.......... Please help me resolve this issues..... I have given my configuration bellow;; RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE) ; RCC_USARTCLKConfig(RCC_USART1CLK_SYSCLK); GPIO_InitStructure.GPIO_Pin = UART_TX_PIN ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2; GPIO_Init(UART_TX_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = UART_DTR_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2; GPIO_Init(UART_DTR_PORT, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = UART_RX_PIN ; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(UART_RX_PORT, &GPIO_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); USART_DeInit(USART1); USART_InitStructure.USART_BaudRate = 9600; USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_Init(USART1, &USART_InitStructure); // USART_ITConfig(USART1, USART_IT_TXE, DISABLE); USART_ITConfig(USART1, USART_IT_TC, ENABLE); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); USART_Cmd(USART1, ENABLE); /////////////////UART1 IRQ handler?????????????????????? void USART1_IRQHandler(void) { if(USART_GetITStatus(USART1, USART_IT_RXNE)!= RESET) { USART_ClearITPendingBit(USART1, USART_IT_RXNE); } if(USART_GetITStatus(USART1, USART_IT_TC)!= RESET) { USART_ClearITPendingBit(USART1, USART_IT_TC); send_ctr++; if(send_ctr <= 13) { uart_send_data = uart_msg[send_ctr]; USART_SendData(USART1, uart_send_data); } else send_ctr = 0; } } #provide-complete-code #stm32f051c8t6-usart-hanging-prob