cancel
Showing results for 
Search instead for 
Did you mean: 

USART3 on STM32F4-Discovery

DNA-)
Associate III
Posted on November 30, 2012 at 16:47

Hi!

Just before starting my post, i would like to thanks the people of this very very usefull forum. A lots of topics helps me in my newly design. So, yes, i'm designing a new board, and i'm evaluating my software on the DiscoveryBoard. So my question is :: How can i send and receive several lines using interrupts but, if possible without DMA? I'm using USART3 on PD8 & PD9. I've already made this software below :

void Init_Uart3(void){ 
GPIO_InitTypeDef GPIO_InitStructure; 
USART_InitTypeDef USART_InitStructure; 
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_Rx | USART_Mode_Tx; 
// GPIO_InitTypeDef GPIO_InitStructure; 
//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_Init(USART3, &USART_InitStructure); 
// Enable USART 
USART_Cmd(USART3, ENABLE); 
}

and with this in my 'main' i can send a character :

while (USART_GetFlagStatus(USART3, USART_FLAG_TC) == RESET); 
USART_SendData(USART3, 'b');

As you can see, it is just polling for sending, but i've nothing to receive any character... I would like to use the interrupts, but i've not any hint to start.. And you? Maybe someone have already done it andd can help me? an exemple? Any help will be welcome! By the way, i should mention that i have as TTL-RS232 translator between the board and my comp. I'm using IAR EWARM. Dave. #usart-stm32
10 REPLIES 10
jay1991
Associate II
Posted on May 11, 2016 at 11:23

Thank you... it worked for me.