cancel
Showing results for 
Search instead for 
Did you mean: 

L151xx USART RX Load Behavior

raptorhal2
Lead
Posted on March 25, 2015 at 15:06

I am having a problem getting an Adafruit FTDI Serial TTL-232 Serial USB adapter to work with USART1 on an STM32L1 processor.

When the adapter is not connected to the processor, or when the processor is powered and in a reset state, the TX line is appropriately high at 3V and goes appropriately low when bits are being sent.

Stepping through the code - when the GPIO_Init for pin 7 is executed in the code below, the FTDI TX signal goes to less than 1 volt, and appropriately to zero when bits are being sent.

STM data sheets are silent on USART loading in AF mode.

The FTDI data sheet shows no pullups for MCU interfaces, and I have never had to use pullups for a MAX232 interface.

Anybody have insights as to what is happening ?

Cheers, Hal

void USART1_Config(void)

{

  //Initialize the USART to N 8 1

  USART_InitTypeDef USART_InitStructure;

 

  USART_InitStructure.USART_BaudRate = 300;

  USART_InitStructure.USART_WordLength = USART_WordLength_8b; //=9 if Parity_Yes

  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;

 

  // Enable GPIOB clock

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);

 

  //Enable the USART RCC clock

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

 

  //Set USART pins to alternate function 7

  GPIO_InitTypeDef GPIO_InitStructure;

 

  GPIO_PinAFConfig(GPIOB, GPIO_Pin_6, GPIO_AF_USART1);

  GPIO_PinAFConfig(GPIOB, GPIO_Pin_7, GPIO_AF_USART1);

 

  //Configure USART1 pins PB6 (tx) & PB7 (rx)

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

 

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;

  GPIO_Init(GPIOB, &GPIO_InitStructure);

 

  USART_Init(USART1, &USART_InitStructure);

 

  //Enable the USART peripheral

  USART_Cmd(USART1, ENABLE);

 

  //Enable the Receive interrupt

  USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

}
1 REPLY 1
raptorhal2
Lead
Posted on March 25, 2015 at 19:28

Problem solved with the help of Kardkon's post.

GPIO_PinAFConfig(GPIOB, GPIO_Pin_6, GPIO_AF_USART1);

GPIO_PinAFConfig(GPIOB, GPIO_Pin_7, GPIO_AF_USART1);

needs to be:

GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1);

GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);

Cheers, Hal