Question
UART Windows problem.
Posted on January 04, 2012 at 13:41
Hello. I have a stm32f103vet6. I see that data goes to PC, but I don't see anything on input in PC.My code for stm32:
&sharpinclude ''stm32F10x.h''u8 SMS[]=''Hello, my name is STM32F100RB!'';int main(void){ u32 tmp=0; RCC->CR|=RCC_CR_HSEON; // ???????? ????????? HSE. while (!(RCC->CR & RCC_CR_HSERDY)) {} // ???????? ?????????? HSE. RCC->CFGR &=~RCC_CFGR_SW; // ???????? ???? SW0, SW1. RCC->CFGR |= RCC_CFGR_SW_HSE; // ??????? HSE ??? ???????????? SW0=1. RCC->APB2ENR|= RCC_APB2ENR_IOPAEN; // ????????? ???????????? ????? A. RCC->APB2ENR|= RCC_APB2ENR_AFIOEN; // ???????????? ?????????????? ??????? GPIO. RCC->APB2ENR|= RCC_APB2ENR_USART1EN; // ????????? ???????????? USART1. GPIOA->CRH |= GPIO_CRH_MODE9; // ????? TX PA.9 - ?? ?????. GPIOA->CRH &=~GPIO_CRH_CNF9; GPIOA->CRH |=GPIO_CRH_CNF9_1; // ?????????????? ?????. USART1->CR1 |=(USART_CR1_RE | USART_CR1_TE); // ????????? ?????? RX, TX - PA10, PA9. // ???????? 115.2 kbps. USARTDIV=FSYS/(16*baud) = 8e6/(16*115200) = 4,34. USART1->BRR=(4<<4); // ????? ????? ???????????? ??????? USART1. USART1->BRR|=5; // ??????? ?????*16 = 0,34*16 = 5 (???). USART1->CR1 |=USART_CR1_UE; // ????????? USART1. while (SMS[tmp]) // ???? ?? ????? ??????... { while (!(USART1->SR & USART_SR_TXE)) {} // ????? ???????????? ??????. USART1->DR=SMS[tmp]; tmp++; // ????????? ????. } int i=0; while (1) { delay(200000); while (SMS[tmp]) // ???? ?? ????? ??????... { while (!(USART1->SR & USART_SR_TXE)) {} // ????? ???????????? ??????. USART1->DR=SMS[tmp]; tmp++; // ????????? ????. } tmp=0; }}void delay(__IO uint32_t nCount){ for(; nCount!= 0;nCount--);} #stm32 #serial #uart #stm32vet6