USART setup example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2009-02-11 4:27 AM
USART setup example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
Hello everyone. Please can anyone indicate to me a good example about USART setup in STM32F101x4? Many Thanks Johann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
The ST FWLib includes a whole section full of USART examples.
Your tool provider probably also provides examples - like the classic ''Hello, World!''- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
Thanks. Please is it possible to indicate where the library is on the ST site as could not find it. many thanks Johann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
Here is the link for the
http://www.st.com/mcu/modules.php?name=mcu&file=familiesdocs&FAM=110#Firmware
. Enjoy it ;)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
Hello found the link but could not find the example Hello World. Im following other examples but still cannot transmit to the hyperterminal. Im using and IC to convert to the required logic signals. Thanks Johann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
Thanks. If a set up the code will put it on the forum as I did with the DMA Johann
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
im using this code: Thanks
void USART_Set_up(void) { USART_InitTypeDef USART_InitStructure; //declaration of structure // USART_ClockInitTypeDef USART_ClockInitStructure; USART_DeInit(USART1); //places USART1 to default reset value 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_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); /* Enable the USART Transmoit interrupt: this interrupt is generated when the USART1 transmit data register is empty */ //USART_ITConfig(USART1, USART_IT_TXE, ENABLE); /* Enable the USARTx */ USART_Cmd(USART1, ENABLE); } /* Send one HalfWord on USART1 */ USART_SendData(USART1, 0x26); //38 decimal- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
You need to activate the clock of the serial before using any usart function.
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE) You also need to configure the usart pins with something like this RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); /* USART1 Rx */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOA, &GPIO_InitStructure); /* USART1 Tx */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure);- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 4:02 AM
Dear brunoalltest. Many thanks the USART is transmitting. However I'm getting a different character in the hyperterminal. Please if you have time,do I need to use this line:
USART_SendData(USART1, 0x26); //38 decimal /* Loop until the end of transmission */ while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) {} Im putting this line in a timer interrupt every 200us/ Thanks Johann