2013-05-24 08:08 AM
Background: I have a lot of experience with Atmel processors (Arduino) and some experience with M68332 processors. Both have widely available examples and forums that help new user get started. With a running example program, I can experiment, change commands around, and rapidly learn.
I'm struggling to find the same type of resources with my transistion to ARM processors. There are examples, but they don't work without major modifications. Major modifications that aren't trivial for someone who is just starting to learn. I have a Keil MCBSTM32F400 board and the Keil uVision IDE. So far, I have about half of the functions working (LCD, RTC, USB hosting, buttons, etc), but I'm struggling with some of the remaining functions. The UART seems to be the most difficult for me. The ST standard peripherals library 1.1.0 was suggested as a starting point. But those are not fully compatible with that Keil board. With respect to the UART, I am trying the standard peripherals library USART_Printf example, but run into missing functions such as STM_EVAL_COMInit() and that just stops me dead in my tracks. Other online examples are similar: they are ultimately written for one prototyping board, but leave everyone else in the dark. Is there a guide on how to get the Standard Peripherals Library working with other boards? Is there a good book that you recommend? The processor data sheet is helpful, but certainly isn't written for the new user. Do any of you have the missing STM_EVAL_COMInit() function code that you can post? Thanks.2013-05-24 08:41 AM
Do any of you have the missing STM_EVAL_COMInit() function codethat you can post?
It will beunder the Utility directory for the specific boards, in the aforementioned FW library release. Got grep? You'd be better off just using the FW library without those unless you port the board support code to your board.
// STM32 USART3 (Tx PB.10, Rx PB.11) STM32F4 Discovery - sourcer32@gmail.com
#include ''stm32f4_discovery.h''
/**************************************************************************************/
void RCC_Configuration(void)
{
/* --------------------------- System Clocks Configuration -----------------*/
/* USART3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
/* GPIOB clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
}
/**************************************************************************************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*-------------------------- GPIO Configuration ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Connect USART pins to AF */
GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3); // USART3_TX
GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3); // USART3_RX
}
/**************************************************************************************/
void USART3_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
/* USARTx configuration ------------------------------------------------------*/
/* USARTx configured as follow:
- BaudRate = 9600 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 = 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(USART3, &USART_InitStructure);
USART_Cmd(USART3, ENABLE);
}
/**************************************************************************************/
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
USART3_Configuration();
while(1)
{
while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); // Wait for Empty
USART_SendData(USART3, 0x49); // Send 'I'
}
while(1); // Don't want to exit
}