cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L100RBT6 USART1 RAMAP PB6-7

MariuszG
Associate II
Posted on June 23, 2014 at 11:21

Hello,

I have problem with USART1. Unfortunately I can't use dedicated pins (PA9-10). Since few days I'm trying to find some information about pin remapping in STM32L There is no MAPR register like in STM32F1. How can I resolve this problem? Where can I found more information? I use Std library. Here is my USART1 initialization code below:

USART_InitTypeDef USART_InitStruct;
RCC->AHBENR|=RCC_AHBENR_GPIOBEN;
RCC->APB2ENR|=RCC_APB2ENR_USART1EN; 
gpio_pin_cfg(GPIOB, 6 , GPIO_AF7_PP_10MHz); 
//USART1 Tx
gpio_pin_cfg(GPIOB, 7 , GPIO_AF7_PP_10MHz); 
//USART1 Rx 
USART_InitStruct.USART_BaudRate=9600; 
USART_InitStruct.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode=USART_Mode_Tx;
USART_InitStruct.USART_WordLength = USART_WordLength_8b;
USART_InitStruct.USART_StopBits = USART_StopBits_1;
USART_InitStruct.USART_Parity = USART_Parity_No ;
USART_Init(USART1, &USART_InitStruct);
USART_Cmd(USART1, ENABLE);

#stm32l100-uart-remap
2 REPLIES 2
Posted on June 23, 2014 at 13:52

Something like this should work

// sourcer32@gmail.com - STM32L15x USART1 Demo 9600 8N1
#include ''stm32l1xx.h''
void main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* Assumes CMSIS and SystemInit() set up clocks before calling main() */
/* Enable GPIO B clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
/* Enable USART1 clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
/* Configure USART Rx & Tx as alternate function */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Mux out USART1 Rx & Tx */
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1); // PA2 USART1_TX
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1); // PA3 USART1_RX
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_None;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
/* USART configuration */
USART_Init(USART1, &USART_InitStructure);
/* Enable USART */
USART_Cmd(USART1, ENABLE);
while(1)
{
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); /* Wait while TX full */
USART_SendData(USART1, 0x55);
}
}

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
MariuszG
Associate II
Posted on June 24, 2014 at 09:18

Yes its works. I tried to find something what does not exist in this MCU. Thanks for help.