cancel
Showing results for 
Search instead for 
Did you mean: 

Com port on Nucleo F030 board?

stthormj9
Associate II
Posted on August 02, 2016 at 03:06

I  used the mbed compiler to make and download the Nucleo_printf program, but I'm not getting any serial output.  I'm using Tera Term on Com23 @ 9600-8-n-1, no flow control.

Is there a step I'm missing?

What baud rates does the VCP support?  Do you have to enable it before using it?

#nucleo
9 REPLIES 9
Posted on August 02, 2016 at 03:28

I don't use mbed. The VCP should work at 9600 8N1 or 115200 8N1 without issues. On other Nucleo boards this is USART2 with PA2/PA3, you'd need to double check the board for the F030

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 02, 2016 at 04:28

Here is how I've used them in C

/* STM32 USART2 PA.2 Tx, PA.3 Rx STM32F030R8 NUCLEO sourcer32@gmail.com */
#include ''stm32f0xx.h''
/**************************************************************************************/
void RCC_Configuration(void)
{
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
}
/**************************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
// PA.2 USART2_TX, PA.3 USART2_RX
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);
/* Configure USART2 pins: Rx and Tx ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
/**************************************************************************************/
void USART2_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
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_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2,ENABLE);
}
/**************************************************************************************/
void OutString(char *s)
{
while(*s)
{
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // Wait for Empty
USART_SendData(USART2, *s++); // Send Char
}
}
/**************************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
USART2_Configuration();
OutString(''Welcome to Nucleo F030R8

'');
while(1)
{
uint16_t Data;
while(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET); // Wait for Char
Data = USART_ReceiveData(USART2); // Collect Char
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // Wait for Empty
USART_SendData(USART2, Data); // Echo Char
}
}
/**************************************************************************************/
#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

'', file, line) */
/* Infinite loop */
while (1)
{}
}
#endif
/**************************************************************************************/

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stthormj9
Associate II
Posted on August 02, 2016 at 20:30

Ok weird.  My reply didn't show up so I'm going to post it again...

What kit does this work with?  Mine (Keil uvision 5, STM32Cube HAL v 1.4.0) is complaining about many unresolved symbols.

Posted on August 02, 2016 at 21:08

I use the Standard Peripheral Library (SPL), bottom of the page if you ignore all the Cube stuff.

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-libraries/stsw-stm32048.html

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stthormj9
Associate II
Posted on August 02, 2016 at 21:35

Ok, that goes a long way.  How do you configure the SPL for the processor (I'm getting messages about USART3 and PORTE -- which are not on this micro)?

Thank you very very much!

Posted on August 02, 2016 at 22:40

Set compiler defines

USE_STDPERIPH_DRIVER,STM32F0XX

or

USE_STDPERIPH_DRIVER,STM32F030,USE_DEFAULT_TIMEOUT_CALLBACK

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stthormj9
Associate II
Posted on August 03, 2016 at 14:23

Ok, got it to compile -- I first got the usart_printf example in StdPeriph to compile (but that didn't work), then I replaced the main.c with your example.  Still compiles.  But I don't see any output on the serial port nor if I hook a oscilloscope to PA2... and I can't figure out why -- the code seems straightforward.

I've tried with 2 F030R8 nucleo boards -- was there a bad batch of STM32F030R8's (or nucleo -- but if that's the case I should still see it in the oscilloscope)?

stthormj9
Associate II
Posted on August 03, 2016 at 20:04

A-ha!  After I made the bouncy program, I still couldn't see anything.  Looking through the schematics, you have to make SB62 & SB63 so you can see it on the expansion connectors -- did that, and now I see serial traffic on the oscope.

The VCP doesn't seem to work, but I'll make a new thread for that now that I have serial working.  Many thanks for helping me with this, @clive1!

Posted on August 03, 2016 at 21:10

I used it on a stock Nucelo F030 board last night, no modifications.

You should be able to see the VCP pins at CN3 RX/TX by the SWD header. Using ClearTerminal at 9600 8N1. Will double check the VCP driver version when I get back.

Have it send 'U' in a loop, scope that and double check baud rate.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..