2014-03-26 12:51 PM
Hi, I have an error in my code and I can not seem identifying the problem
The erreur is : ..\main.c(97): error: #169: expected a declarationThis is my code /**************************************************************************************/ #include ''stm32f4_discovery.h'' #include <stm32f4xx_usart.h> GPIO_InitTypeDef GPIO_InitStructure; USART_InitTypeDef USART_InitStructure;void RCC_Configuration(void);void GPIO_Configuration(void);void USART1_Configuration(void);void RCC_Configuration(void){ /* --------------------------- System Clocks Configuration -----------------*/ /* USART1 clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE); /* GPIOA clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOD, ENABLE);} /**************************************************************************************/ void GPIO_Configuration(void){ /*-------------------------- GPIO Configuration ----------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; 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(GPIOA, &GPIO_InitStructure); /* Connect USART pins to AF */ GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); // USART1_TX GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); // USART1_RX GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; 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(GPIOD, &GPIO_InitStructure);} /**************************************************************************************/ void USART1_Configuration(void){ /* 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(USART1, &USART_InitStructure); USART_Cmd(USART1, ENABLE);} /**************************************************************************************/ char test;int main(void){ RCC_Configuration(); GPIO_Configuration(); USART1_Configuration(); while(1) { uint16_t Data; while(USART_GetITStatus(USART1, USART_IT_RXNE) == RESET); // Wait for Char Data = USART_ReceiveData(USART1); // Collect Char while(USART_GetITStatus(USART1, USART_IT_TXE) == RESET); // Wait for Empty USART_SendData(USART3, Data); // Echo Char } while(1); // Don't want to exit}}2014-03-26 01:01 PM
One too many closing braces? Helps when you paste code with line number references to use the ''Format Code Block'' and check Line Numbers
Random reference to USART3 Also be aware, and I think I've pointed this out before, you cannot use PA9 on the STM32F4-Discovery, read the schematic.2014-03-26 01:08 PM
2014-03-26 01:15 PM
One too many closing braces?
2014-03-26 01:49 PM
plz my program dont work i can't send any data to an other xbee can you help me to solve this problem
2014-03-26 01:54 PM
86. } <--- WHAT DOES THIS PAIR WITH?
PA9 / USART1 is NOT usable on the STM32F4-DISCO board.USART2 PA2/PA3 should be usable.[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/USART%20example%20code%20for%20Nucleo%20F401RE&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx¤tviews=9]Example Here2014-03-26 04:19 PM
I tried but it does not work here is my new code
2014-03-26 04:49 PM
I tried but it does not work here is my new code
Yeah, I'm not sure what ''not working'' means, and how I would debug it. The ''return 0'' in the while() loop of main() looks out of place.2014-03-26 07:04 PM
i have a same problem