2016-08-01 06:06 PM
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? #nucleo2016-08-01 06:28 PM
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
2016-08-01 07:28 PM
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
/**************************************************************************************/
2016-08-02 11:30 AM
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.2016-08-02 12:08 PM
I use the Standard Peripheral Library (SPL), bottom of the page if you ignore all the Cube stuff.
2016-08-02 12:35 PM
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!
2016-08-02 01:40 PM
Set compiler defines
USE_STDPERIPH_DRIVER,STM32F0XXorUSE_STDPERIPH_DRIVER,STM32F030,USE_DEFAULT_TIMEOUT_CALLBACK2016-08-03 05:23 AM
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)?
2016-08-03 11:04 AM
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!
2016-08-03 12:10 PM
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.