cancel
Showing results for 
Search instead for 
Did you mean: 

USART on F4 DISCOVERY

joerg23
Associate II
Posted on January 08, 2012 at 11:23

I�m a newbe at C and try to get some

experience

on this board.

Working on GPIOs are fine.

Now I'm trying USART but is not work. Noting come out the TX Pin on USART3 at GPIO PIN D8 and D9.

Mabey someone can have a look on my

attached

TrueStudio Projekt.

Thanks al lot.

regards  Joerg

#usart3
1 REPLY 1
Posted on January 08, 2012 at 16:00

Atollic Lite doesn't support printf/scanf, retargeting also might complicate testing, and I'm not invested in the full version.

This thread deals with the pin configuration [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32F4DISCOVERY/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32F4DISCOVERY/USART problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580002E3D0FFCC5A9AA4A9C29C3EECB7CCDBF&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32F4DISCOVERY/AllItems.aspx?Paged%3DTRUE%26p_StickyPost%3D%26p_DiscussionLastUpdated%3D20111211%252002%253a34%253a21%26p_ID%3D114%26View%3D%257b29BB1FE1%252d2414%252d419D%252dBD08%252d909CF38FB9FC%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41&currentviews=338]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32F4DISCOVERY/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32F4DISCOVERY%2fUSART%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580002E3D0FFCC5A9AA4A9C29C3EECB7CCDBF&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32F4DISCOVERY%2FAllItems%2Easpx%3FPaged%3DTRUE%26p%5FStickyPost%3D%26p%5FDiscussionLastUpdated%3D20111211%252002%253a34%253a21%26p%5FID%3D114%26View%3D%257b29BB1FE1%252d2414%252d419D%252dBD08%252d909CF38FB9FC%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41¤tviews=338 Something like this should demonstrate basic output to USART3

//configure clock for USART
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
//configure clock for GPIO
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
//configure AF
GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_USART3);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_USART3);
//configure ports, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_Init(GPIOD, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 115200;
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(USART3, &USART_InitStructure);
/* Enable USART */
//USART_Cmd(USART3, ENABLE);
while(1)
{
while (USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
USART_SendData(USART3, (uint8_t)'Z');
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..