AnsweredAssumed Answered

UART1 TX pin as 5V Tolerant - Should be OK?

Question asked by dbyrnes47 on Oct 25, 2013
I'm trying to setup some communications between an STM32L152 series MCU with an ATMEGA16. The Atmega uses 5V logic high. I read the Datasheet and found that the UART1 RX pin is 5V tolerant on the STM32 so I should be able to take in 5V packets from the Atmega. Here is my GPIO and UART initializaton:

  USART_InitTypeDef USART_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
 
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);    // Enable GPIO A bank clock
  
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);  // Enable USART1 clock
 

/* Configure Alternate Function pin muxing fabric to escape USART1 Rx and Tx */
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9,  GPIO_AF_USART1);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
   
/* Configure USART1 pins:  Rx and Tx */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10 |
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_400KHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
 
/* Configure USART1 settings */
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_9b;
  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(USART1, &USART_InitStructure);
 
USART_Cmd(USART1,ENABLE); // Enable USART1

/* USART1 GPIO Configuration:  
     PA9     ------> USART1_TX
     PA10    ------> USART1_RX */

I just wanted to make sure I had everything setup correctly before I start sending 5V logic to the 3V3 STM32. 

Thanks in advance for any help!

Outcomes