UART Windows problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-01-04 4:41 AM
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- Labels:
-
STM32F1 Series
-
UART-USART
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-01-04 12:17 PM
Instead of ''int i = 0;'' you need ''tmp = 0;''
You might consider using ''USART1->BRR = (8000000 / 115200);'' The code otherwise seems to work, so consider for a minute how you have the USART connected to the PC. The STM32 generates CMOS 3V Serial signalling, This is NOT compatible with RS232 signalling used by the PC. You need buffering circuitry.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-01-04 1:22 PM
Thanks for the reply. I'm use PL2303HX USB to TTL Converter Module. I tried to read data in PuTTY and Realterm, but a console has been empty when STM32 board sends data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-01-04 3:51 PM
Then consider how you have it wired, that you have a ground, and the TX of the STM32 goes to the RXD of the receiving device.
Stick a scope on it if you need to confirm the bit/baud rate. If you suspect the 8MHz HSE, then skip that and use the 8MHz HSI which brings the STM32 up. Code has been tested on a VL-Discovery with a CMOS Serial to USB converter, and works at 115200 8N1Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-01-05 1:07 AM
Thank you very much! You are help me as no one before! The problem is in how I wired it. I connected it GND->GND, TXD->TX, RXD->RX, 5v->VCC, but as you said I had to replace RXD with TXD.
