OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 7512|回复: 5

问,编译usart.c无法连接,怎么改? 错误提示及源码文件都粘贴如下:

[复制链接]

10

主题

30

帖子

0

精华

初级会员

Rank: 2

积分
90
金钱
90
注册时间
2014-5-17
在线时间
0 小时
发表于 2014-7-5 09:12:43 | 显示全部楼层 |阅读模式
5金钱
usart.h文件:
#ifndef __USART_H
#define __USART_H

//#include "stm32f10x_lib.h"
// #include "stm32f10x.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_nvic.h"
#include "stm32f10x_rcc.h"
//////////////////////////////////////////////////////////////////////////////////  
//注释................
//////////////////////////////////////////////////////////////////////////////////

//如果想串口中断接收,请不要注释以下宏定义
// #define GPIO_Pin_9                 ((uint16_t)0x0200)  /*!< Pin 9 selected */
// #define GPIO_Pin_10                ((uint16_t)0x0400)  /*!< Pin 10 selected */
//typedef unsigned long  u32;                         
void USART1_Configuration(u32 bound);

#endif
usart.c
void USART1_Configuration(u32 bound)
{
GPIO_InitTypeDef GPIO_InitStructure; //#include "stm32f10x_gpio.h"
USART_InitTypeDef USART_InitStructure; //  #include "stm32f10x_usart.h"
USART_ClockInitTypeDef  USART_ClockInitStructure;
NVIC_InitTypeDef NVIC_InitStructure; //#include "stm32f10x_nvic.h"

RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 |RCC_APB2Periph_USART1, ENABLE  );  //#include "stm32f10x_rcc.h"
USART_DeInit(USART1);  //复位串口1

//USART1_TX   PA.9
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //复用推挽输出
GPIO_Init(GPIOA, &GPIO_InitStructure); //初始化PA9

//USART1_RX  A.10
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入
GPIO_Init(GPIOA, &GPIO_InitStructure);  //初始化PA10

//Usart1 NVIC 配置

// NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
// NVIC_InitStructure.NVIC_IRQChannel = 37;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3 ;//抢占优先级3
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ通道使能
NVIC_Init(&NVIC_InitStructure); //根据指定的参数初始化VIC寄存器


USART_ClockInitStructure.USART_Clock = USART_Clock_Disable; // 时钟低电平活动
USART_ClockInitStructure.USART_CPOL = USART_CPOL_Low; // 时钟低电平
USART_ClockInitStructure.USART_CPHA = USART_CPHA_2Edge; // 时钟第二个边沿进行数据捕获
USART_ClockInitStructure.USART_LastBit = USART_LastBit_Disable; // 最后一位数据的时钟脉冲不从SCLK输出
/* Configure the USART1 synchronous paramters */
USART_ClockInit(USART1, &USART_ClockInitStructure); // 时钟参数初始化设置
 
USART_InitStructure.USART_BaudRate = bound;    // 波特率为:115200
USART_InitStructure.USART_WordLength = USART_WordLength_8b;  // 8位数据
USART_InitStructure.USART_StopBits = USART_StopBits_1;  // 在帧结尾传输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;  // 发送使能+接收使能
/* Configure USART1 basic and asynchronous paramters */
USART_Init(USART1, &USART_InitStructure);
    
  /* Enable USART1 */
USART_ClearFlag(USART1, USART_IT_RXNE); //清中断,以免一启用中断后立即产生中断
USART_ITConfig(USART1,USART_IT_RXNE, ENABLE); //使能USART1中断源
USART_Cmd(USART1, ENABLE); //USART1总开关:开启 
}


compiling usart.c...
linking...
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol g_IMURaw_Data (referred from imu_calculation.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol GPIO_Init (referred from iic.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol NVIC_Init (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol RCC_APB2PeriphClockCmd (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol USART_ClearFlag (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol USART_ClockInit (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol USART_Cmd (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol USART_DeInit (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol USART_ITConfig (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol USART_Init (referred from usart.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol RCC_APB1PeriphClockCmd (referred from timer.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol TIM_Cmd (referred from timer.o).
..\OBJ\Navigation.axf: Error: L6218E: Undefined symbol TIM_TimeBaseInit (referred from timer.o).
Target not created

如上错误怎么改?  注明不能使用stm32f10x.h这个库, 因为使用这个库我的工程里头好多函数都要改

最佳答案

查看完整内容[请看2#楼]

回复【4楼】augustedward: --------------------------------- 改成這样子就可以了: #include "stm32f10x_gpio.h" #include "stm32f10x_usart.h" #include "misc.h" #include "stm32f10x_rcc.h" #include "stdio.h" 因为3.50以上的nvic不在有专门 stm32f10x_nvic.h来写了,而是放在了misc.h中,所以包含 misc.h就可以了
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

10

主题

30

帖子

0

精华

初级会员

Rank: 2

积分
90
金钱
90
注册时间
2014-5-17
在线时间
0 小时
 楼主| 发表于 2014-7-5 09:12:44 | 显示全部楼层
回复【4楼】augustedward:
---------------------------------
改成這样子就可以了:
#include "stm32f10x_gpio.h"
#include "stm32f10x_usart.h"
#include "misc.h"
#include "stm32f10x_rcc.h"
#include "stdio.h"
因为3.50以上的nvic不在有专门 stm32f10x_nvic.h来写了,而是放在了misc.h中,所以包含 misc.h就可以了
回复

使用道具 举报

120

主题

7878

帖子

13

精华

资深版主

Rank: 8Rank: 8

积分
12012
金钱
12012
注册时间
2013-9-10
在线时间
427 小时
发表于 2014-7-5 12:34:41 | 显示全部楼层
是不是没添加stm32f10x_usart.h头文件
现在,程序把烂铜烂铁变得智能化了,人呢,一旦离开了这烂铜烂铁就不知道干啥了
回复

使用道具 举报

10

主题

30

帖子

0

精华

初级会员

Rank: 2

积分
90
金钱
90
注册时间
2014-5-17
在线时间
0 小时
 楼主| 发表于 2014-7-5 13:13:22 | 显示全部楼层
回复【2楼】Badu_Space:
---------------------------------
加了, 看我上面的头文件源码,里头什么都加了
usart.h文件:
#ifndef __USART_H
#define __USART_H

//#include "stm32f10x_lib.h"
// #include "stm32f10x.h"
#include "stm32f10x_gpio.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_nvic.h"
#include "stm32f10x_rcc.h"
//////////////////////////////////////////////////////////////////////////////////
回复

使用道具 举报

9

主题

1385

帖子

0

精华

论坛元老

Rank: 8Rank: 8

积分
12105
金钱
12105
注册时间
2013-3-8
在线时间
1286 小时
发表于 2014-7-5 14:15:47 | 显示全部楼层
//#include "stm32f10x_lib.h" 
#include "stm32f10x.h" 
#include "stm32f10x_gpio.h" 
#include "stm32f10x_usart.h" 
#include "stm32f10x_nvic.h" 
#include "stm32f10x_rcc.h" 
这样改试试
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165540
金钱
165540
注册时间
2010-12-1
在线时间
2117 小时
发表于 2014-7-5 23:13:28 | 显示全部楼层
回复【5楼】stm3201:
---------------------------------
谢谢分享。
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-7-6 14:56

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表