cancel
Showing results for 
Search instead for 
Did you mean: 

Which pin should I have to use to test USART1?

Carter Lee
Associate III
Posted on September 09, 2017 at 16:52

Hi.

I'd like to test UART in STM32F429-DISCO kit, and I buy UART to USB board 

0690X000006046CQAQ.jpg

But I don't know what pins are using in UART test with .STM32F4xx_DSP_StdPeriph_Lib_V1.8.0

Could you please let me know which pins should I have to connect between 

STM32F429-DISCO kit and UART

 to

USB

 board ?

0690X00000608BVQAY.png
6 REPLIES 6
Posted on September 09, 2017 at 17:13

There is a pin list on page 20 of the User Manual

http://www.st.com/content/ccc/resource/technical/document/user_manual/6b/25/05/23/a9/45/4d/6a/DM00093903.pdf/files/DM00093903.pdf/jcr:content/translations/en.DM00093903.pdf

 

Isn't USART1 connected to the VCP on the DISC1 board? via PA9 and PA10

SB11 and SB15 control connectivity there. These could be removed and signals would be available at the headers.

USART1_TX going to the RX pin of an adapter.

Some free pins seems to be PD5 USART2_TX, PC11 USART3_RX, PC12 UART5_TX, PF6 UART7_RX

Chip pin lists can be found in the Data Sheet

http://www.st.com/content/ccc/resource/technical/document/datasheet/03/b4/b2/36/4c/72/49/29/DM00071990.pdf/files/DM00071990.pdf/jcr:content/translations/en.DM00071990.pdf

 

Your life will be a lot easier if you read, digest, and understand the documentation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 09, 2017 at 17:51

 ,

 ,

Thanks for letting me know that.

Currently I'm referring en.DM00071990.pdf There is some information about ,STM32F429xx.

and ,STM32F4xx_DSP_StdPeriph_Lib_V1.8.0 USART example code.

But there is no connection information. ,

Might be you are saying this

0690X000006043dQAA.jpg0690X0000060441QAA.jpg

I'm actually confused that manual saying USART1_TX : PA9, PB6 , and USART1_RX: PA10, PB7.

How am I supposed to know which pin is used for USART1 TX,RX.

Even the example code does not use alternate mode. how do we know which function does it use after reset.

What I mean is for example PB6's function is defined as TIM4_CH1, I2C1_SCL, USART1_TX,CAN2_TX...

Here 's example code of USART, I can't see the any information of alternate mode.

/**

 ,

******************************************************************************

 ,

* @file USART/USART_Printf/main.c

 ,

* @author MCD Application Team

 ,

* @version V1.8.0

 ,

* @date 04-November-2016

 ,

* @brief Main program body

 ,

******************************************************************************

 ,

* @attention

 ,

*

 ,

* <,h2>,<,center>,&,copy, COPYRIGHT 2016 STMicroelectronics<,/center>,<,/h2>,

 ,

*

 ,

* Licensed under MCD-ST Liberty SW License Agreement V2, (the ''License''),

 ,

* You may not use this file except in compliance with the License.

 ,

* You may obtain a copy of the License at:

 ,

*

 ,

*

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fsoftware_license_agreement_liberty_v2

 ,

*

 ,

* Unless required by applicable law or agreed to in writing, software

 ,

* distributed under the License is distributed on an ''AS IS'' BASIS,

 ,

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 ,

* See the License for the specific language governing permissions and

 ,

* limitations under the License.

 ,

*

 ,

******************************************************************************

 ,

*/

/* Includes ------------------------------------------------------------------*/

 ,

♯ include ''main.h''

/** @addtogroup STM32F4xx_StdPeriph_Examples

 ,

* @{

 ,

*/

/** @addtogroup USART_Printf

 ,

* @{

 ,

*/

/* Private typedef -----------------------------------------------------------*/

 ,

/* Private define ------------------------------------------------------------*/

 ,

/* Private macro -------------------------------------------------------------*/

 ,

/* Private variables ---------------------------------------------------------*/

 ,

/* Private function prototypes -----------------------------------------------*/

 ,

static void USART_Config(void),

♯ ifdef __GNUC__

 ,

/* With GCC/RAISONANCE, small printf (option LD Linker->,Libraries->,Small printf

 ,

set to 'Yes') calls __io_putchar() */

 ,

♯ define PUTCHAR_PROTOTYPE int __io_putchar(int ch)

 ,

♯ else

 ,

♯ define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)

 ,

♯ endif /* __GNUC__ */

 ,

 ,

/* Private functions ---------------------------------------------------------*/

/**

 ,

* @brief Main program

 ,

* @param None

 ,

* @retval None

 ,

*/

 ,

int main(void)

 ,

{

 ,

/*!<, At this stage the microcontroller clock setting is already configured,

 ,

this is done through SystemInit() function which is called from startup

 ,

files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)

 ,

before to branch to application main.

 ,

To reconfigure the default setting of SystemInit() function, refer to

 ,

system_stm32f4xx.c file.

 ,

*/

/* USART configuration */

 ,

USART_Config(),

 ,

 ,

/* Output a message on Hyperterminal using printf function */

 ,

printf(''\n\rUSART Printf Example: retarget the C library printf function to the USART\n\r''),

while (1)

 ,

{

 ,

}

 ,

}

/**

 ,

* @brief Configures the USART Peripheral.

 ,

* @param None

 ,

* @retval None

 ,

*/

 ,

static void USART_Config(void)

 ,

{

 ,

USART_InitTypeDef USART_InitStructure,

 ,

 ,

/* USARTx configured as follows:

 ,

- BaudRate = 115200 baud

 ,

- Word Length = 8 Bits

 ,

- One Stop Bit

 ,

- No parity

 ,

- Hardware flow control disabled (RTS and CTS signals)

 ,

- Receive and transmit enabled

 ,

*/

 ,

USART_InitStructure.USART_BaudRate = 115200,

 ,

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,

STM_EVAL_COMInit(COM1, &,USART_InitStructure),

 ,

}

/**

 ,

* @brief Retargets the C library printf function to the USART.

 ,

* @param None

 ,

* @retval None

 ,

*/

 ,

PUTCHAR_PROTOTYPE

 ,

{

 ,

/* Place your implementation of fputc here */

 ,

/* e.g. write a character to the USART */

 ,

USART_SendData(EVAL_COM1, (uint8_t) ch),

/* Loop until the end of transmission */

 ,

while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)

 ,

{}

return ch,

 ,

}

♯ ifdef USE_FULL_ASSERT

/**

 ,

* @brief Reports the name of the source file and the source line number

 ,

* where the assert_param error has occurred.

 ,

* @param file: pointer to the source file name

 ,

* @param line: assert_param error line source number

 ,

* @retval None

 ,

*/

 ,

void assert_failed(uint8_t* file, uint32_t line)

 ,

{

 ,

/* User can add his own implementation to report the file name and line number,

 ,

ex: printf(''Wrong parameters value: file %s on line %d\r\n'', file, line) */

/* Infinite loop */

 ,

while (1)

 ,

{

 ,

}

 ,

}

 ,

♯ endif

/**

 ,

* @}

 ,

*/

/**

 ,

* @}

 ,

*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

Posted on September 09, 2017 at 20:37

The function can be multiplexed to multiple pins. The pin basically contains a sixteen way switch which controls which peripheral uses the pin. The secondary table in the Data Sheet describes these with AF0..15 settings.

The code to configure the pins would be under STM_EVAL_COMInit()

The pin via GPIO_Init(), the function via GPIO_AFConfig()

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Shail Shah
Associate II
Posted on September 11, 2017 at 06:12

Hello,  kindly refer data sheet and find the appropriate pin detail for RX and TX. You may use cubeMX software to find the RX and TX pin. Open the

STM32F4xx_DSP_StdPeriph_Lib_V1.8.0

and go to UART init function to check for GPIO use for Rx and Tx pin.
Posted on September 11, 2017 at 04:51

I'm confused that how does GPIO_AFRL[31:0] register exactly do as AFRLx  and trying to understand alternate function as AFRL as the image below.

for example If I set GPIOA_AFRL = 0x

0000_

0000_

0000_

0000_

0000_0000_0111_0100,

Then what happens?

I can't understand the relationship between left and right image at the below.

0690X0000060447QAA.jpg

I can't see the Information of ''

The pin via GPIO_Init(), the function via GPIO_AFConfig()'',

Especially,

void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)

{

uint32_t pinpos = 0x00, pos = 0x00 , currentpin = 0x00;

/* Check the parameters */

assert_param(IS_GPIO_ALL_PERIPH(GPIOx));

assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));

assert_param(IS_GPIO_MODE(GPIO_InitStruct->GPIO_Mode));

assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));

/* ------------------------- Configure the port pins ---------------- */

/*-- GPIO Mode Configuration --*/

for (pinpos = 0x00; pinpos < 0x10; pinpos++)

{

pos = ((uint32_t)0x01) << pinpos;

/* Get the port pins position */

currentpin = (GPIO_InitStruct->GPIO_Pin) & pos;

if (currentpin == pos)

{

GPIOx->MODER &= ~(GPIO_MODER_MODER0 << (pinpos * 2));

GPIOx->MODER |= (((uint32_t)GPIO_InitStruct->GPIO_Mode) << (pinpos * 2));

if ((GPIO_InitStruct->GPIO_Mode == GPIO_Mode_OUT) || (GPIO_InitStruct->GPIO_Mode == GPIO_Mode_AF))

{

/* Check Speed mode parameters */

assert_param(IS_GPIO_SPEED(GPIO_InitStruct->GPIO_Speed));

/* Speed mode configuration */

GPIOx->OSPEEDR &= ~(GPIO_OSPEEDER_OSPEEDR0 << (pinpos * 2));

GPIOx->OSPEEDR |= ((uint32_t)(GPIO_InitStruct->GPIO_Speed) << (pinpos * 2));

/* Check Output mode parameters */

assert_param(IS_GPIO_OTYPE(GPIO_InitStruct->GPIO_OType));

/* Output mode configuration*/

GPIOx->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pinpos)) ;

GPIOx->OTYPER |= (uint16_t)(((uint16_t)GPIO_InitStruct->GPIO_OType) << ((uint16_t)pinpos));

}

/* Pull-up Pull down resistor configuration*/

GPIOx->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pinpos * 2));

GPIOx->PUPDR |= (((uint32_t)GPIO_InitStruct->GPIO_PuPd) << (pinpos * 2));

}

}

}

there's nowhere GPIO_PinAFConfig function especially in that example project.

I think it means that there is no setting about 

AFConfigure.

Posted on September 11, 2017 at 06:21

Where does it can I find in the example code? especially I don't use CUBEMX I'm SPL user.