AnsweredAssumed Answered

USART2 makes trouble

Question asked by ka.hak on Sep 19, 2011
Latest reply on Apr 13, 2012 by ka.hak
Hi,
i own an stm32f103 Board. USART1 is configured as TX via DMA and RX Polling.
I tried to configure the USART2 port TX polling and RX polling.
Confusing thing is that after sending on char to console the board resets in loop and the Console of USART2 prints after each reset a square symbol.
Configuration of USART2:
RCC->APB2ENR |= (RCC_APB2ENR_IOPAEN | RCC_APB2ENR_AFIOEN); 
RCC->APB1ENR |= RCC_APB1ENR_USART2EN; 
GPIO_CONF_OUTPUT_PORT(A,2,ALT_PUSH_PULL,50); 
GPIO_CONF_INPUT_PU_PD(A,GPIO_CM3); 
GPIOA->BSRR = GPIO_BSRR_BS3; 
USART2->CR1 = USART_CR1_UE; //Enable USART ((u16)0x2000) 
USART2->CR2 = 0; //Stopbits 
USART2->CR1 |= USART_CR1_TE; // Transmitter Enable ((u16)0x0008) 
USART2->BRR= 0x45; //Baudrate 115200 
USART2->CR1 |= USART_CR1_RE; 
USART2->CR1 |= USART_CR1_RXNEIE; 
NVIC_SET_PRIORITY(USART2_IRQChannel, 2); 
NVIC_ENABLE_INT(USART2_IRQChannel); 
 
send routine: 
int u2_putchar(int c) 
{ 
while (!(USART2->SR & USART_SR_TXE)); 
USART2->DR = (c & 0xFF); 
return(c); 
} 
 
and in main i call u2_putchar(4); Without this call evrything works. 

Outcomes