Posted on June 13, 2013 at 14:14 this is my code for usart .and i am facing again one error which i found last time ..please suggest me how to remove it .....code is here
#include <stm32f4xx_usart.h>
#include ''stm32f4xx_adc.h''
#include ''stm32f4xx_gpio.h''
#include ''stm32f4xx_rcc.h''
#include ''stm32f4xx.h''
void init_usart(void){
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* enable peripheral clock for USART2 */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
/* GPIOA clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
/* GPIOA Configuration: USART2 TX on PA2 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Connect USART2 pins to AF2 */
// TX = PA2
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2);
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_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE); // enable USART2
}
void Delay(__IO uint32_t nCount)
{
while(nCount--)
{
}
}
int main(void){
init_usart();
uart_puts(''Init complete!'');
while(1){
USART_SendData(USART2, 'v'); // defined in stm32f4xx_usart.h
Delay(0x3FFFFF);
}
}
.ERROR IS HERE
GCC HOME: C:\Program Files (x86)\GNU Tools ARM Embedded\4.7 2013q1\bin
compile:
[mkdir] Created dir: C:\CooCox\CoIDE\workspace\usart\usart\Debug\bin
[mkdir] Created dir: C:\CooCox\CoIDE\workspace\usart\usart\Debug\obj
[cc] 18 total files to be compiled.
[cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Wall -ffunction-sections -g -O0 -flto -fno-builtin -c -DSTM32F407VG -DSTM32F4XX -DUSE_STDPERIPH_DRIVER -D__ASSEMBLY__ -IC:\CooCox\CoIDE\workspace\usart\cmsis_lib -IC:\CooCox\CoIDE\workspace\usart\cmsis_boot -IC:\CooCox\CoIDE\workspace -IC:\CooCox\CoIDE\workspace\usart\cmsis_lib\include -IC:\CooCox\CoIDE\workspace\usart -IC:\CooCox\CoIDE\workspace\usart\cmsis -IC:\CooCox\CoIDE\workspace\usart\STM32F4-Discovery C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_syscfg.c C:\CooCox\CoIDE\workspace\usart\STM32F4-Discovery\stm32f4_discovery_audio_codec.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_usart.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_dac.c C:\CooCox\CoIDE\workspace\usart\cmsis_boot\startup\startup_stm32f4xx.c C:\CooCox\CoIDE\workspace\usart\STM32F4-Discovery\stm32f4_discovery.c C:\CooCox\CoIDE\workspace\usart\main.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_rcc.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_adc.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_gpio.c C:\CooCox\CoIDE\workspace\usart\cmsis_boot\system_stm32f4xx.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_dma.c C:\CooCox\CoIDE\workspace\usart\stm32f4_discovery_callbacks.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_spi.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_i2c.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\stm32f4xx_exti.c C:\CooCox\CoIDE\workspace\usart\cmsis_lib\source\misc.c C:\CooCox\CoIDE\workspace\usart\STM32F4-Discovery\stm32f4_discovery_lis302dl.c
[cc] C:\CooCox\CoIDE\workspace\usart\main.c: In function 'main':
[cc] C:\CooCox\CoIDE\workspace\usart\main.c:59:2: warning: implicit declaration of function 'uart_puts' [-Wimplicit-function-declaration]
[cc] Starting link
[cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles -flto -Wl,-Map=usart.map -O0 -Wl,--gc-sections -Wl,--entry=main -LC:\CooCox\CoIDE\configuration\ProgramData\usart -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\usart/arm-gcc-link.ld -g -o usart.elf ..\obj\stm32f4xx_syscfg.o ..\obj\stm32f4_discovery_audio_codec.o ..\obj\stm32f4xx_usart.o ..\obj\stm32f4xx_dac.o ..\obj\startup_stm32f4xx.o ..\obj\stm32f4_discovery.o ..\obj\main.o ..\obj\stm32f4xx_rcc.o ..\obj\stm32f4xx_adc.o ..\obj\stm32f4xx_gpio.o ..\obj\system_stm32f4xx.o ..\obj\stm32f4xx_dma.o ..\obj\stm32f4_discovery_callbacks.o ..\obj\stm32f4xx_spi.o ..\obj\stm32f4xx_i2c.o ..\obj\stm32f4xx_exti.o ..\obj\misc.o ..\obj\stm32f4_discovery_lis302dl.o -L..\..\..\STM32F4-Discovery -lpdmfilter_gcc
[cc] C:\Users\AKG\AppData\Local\Temp\ccT4as9i.ltrans0.ltrans.o: In function `main':
[cc] C:\CooCox\CoIDE\workspace\usart/main.c:59: undefined reference to `uart_puts'
[cc] collect2.exe: error: ld returned 1 exit status