錯誤提示:
main.c(12): warning: #223-D: function "GPIO_ResetBits" declared implicitly
GPIO_ResetBits(GPIOC,GPIO_Pin_6);
main.c(13): warning: #61-D: integer operation result is out of range
GPIOC->CRL &=~(0x0F<<(uint32_t)4*7);
main.c(15): warning: #223-D: function "GPIO_SetBits" declared implicitly
GPIO_SetBits(GPIOC,GPIO_Pin_7);
main.c: 3 warnings, 0 errors
linking...
.\Objects\jcqld.axf: Error: L6218E: Undefined symbol GPIO_ResetBits (referred from main.o).
.\Objects\jcqld.axf: Error: L6218E: Undefined symbol GPIO_SetBits (referred from main.o).
Not enough information to list image symbols.
Not enough information to list load addresses in the image map.
Finished: 2 information, 0 warning and 2 error messages.
".\Objects\jcqld.axf" - 2 Error(s), 3 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01
以下撰寫的代碼,結合自己的板子,參照網上視頻,查找了些相關問題的網頁,沒有解決
////////main函式///////
#include "stm32f10x_gpio.h"
#include "stm32f10x.h"
int main(void)
{
RCC->APB2ENR |=(1<<4);
GPIOC->CRL &=~(0x0F<<4*6);
GPIOC->CRL |=(1<<4*6);
// GPIOC->ODR |=(1<<6);
GPIO_ResetBits(GPIOC,GPIO_Pin_6);
GPIOC->CRL &=~(0x0F<<(uint32_t)4*7);
GPIOC->CRL |=(1<<4*7);
GPIO_SetBits(GPIOC,GPIO_Pin_7);//這里呼叫gpio_setbits和gpio_resetbits出現過沒定義
}
///////stm32f10x.h///////
#ifndef __STM32F10X_H
#define __STM32F10X_H
typedef unsigned int uint32_t; //定義資料型別
typedef unsigned short uint16_t;
#define PERIPH_BASE ((unsigned int)0x40000000)
#define APB2PERIPH_BASE (PERIPH_BASE+0x10000)
#define AHBPERIPH_BASE (PERIPH_BASE+0x20000) //總線地址變數定義
#define RCC_BASE (AHBPERIPH_BASE+0x1000)//埠時鐘地址變數定義
#define GPIOC_BASE (APB2PERIPH_BASE+0x1000)//埠C地址變數定義
typedef struct //定義GPIO結構體
{
uint32_t CRL;
uint32_t CRH;
uint32_t IDR;
uint32_t ODR;
uint32_t BSRR;
uint32_t BRR;
}GPIO_TypeDef;
typedef struct //定義RCC結構體
{
uint32_t CR;
uint32_t CFGR;
uint32_t CIR;
uint32_t APB2RSTR;
uint32_t APB1RSTR;
uint32_t AHBENR;
uint32_t APB2ENR;
}RCC_TypeDef;
#define RCC ((RCC_TypeDef*)RCC_BASE) //定義RCC基地址為RCC結構體
#define GPIOC ((GPIO_TypeDef*)GPIOC_BASE) //定義GPIO基地址型別為GPIO
//這里最后兩句括號里面的東西,雙括號全包進去和單括號只包*前的內容區別有多大
#endif
///////stm32f10x_gpio.h///////
#ifndef __STM32F10X_GPIO_H
#define __STM32F10X_GPIO_H
#include "stm32f10x.h"
#define GPIO_Pin_0 (uint16_t)0x0001 //二進制:0b0000 0001
#define GPIO_Pin_1 (uint16_t)0x0002 //二進制:0b0000 0010
#define GPIO_Pin_2 (uint16_t)0x0004 //二進制:0b0000 0100
#define GPIO_Pin_3 (uint16_t)0x0008
#define GPIO_Pin_4 (uint16_t)0x0010
#define GPIO_Pin_5 (uint16_t)0x0020
#define GPIO_Pin_6 (uint16_t)0x0040
#define GPIO_Pin_7 (uint16_t)0x0080
#define GPIO_Pin_8 (uint16_t)0x0100
#define GPIO_Pin_9 (uint16_t)0x0200
#define GPIO_Pin_10 (uint16_t)0x0400
#define GPIO_Pin_11 (uint16_t)0x0800
#define GPIO_Pin_12 (uint16_t)0x1000
#define GPIO_Pin_13 (uint16_t)0x2000
#define GPIO_Pin_14 (uint16_t)0x4000
#define GPIO_Pin_15 (uint16_t)0x8000
#define GPIO_Pin_all(uint16_t)0xFFFF
void GPIO_Setbits(GPIO_TypeDef *GPIOx,uint16_t GPIO_pin);
void GPIO_Resetbits(GPIO_TypeDef *GPIOx,uint16_t GPIO_pin);
#endif
///////stm32f10x_gpio.c///////
#include "stm32f10x_gpio.h"
void GPIO_Setbits(GPIO_TypeDef *GPIOx,uint16_t GPIO_pin)
{
GPIOx->BSRR |=GPIO_pin;
}
void GPIO_Resetbits(GPIO_TypeDef *GPIOx,uint16_t GPIO_pin)
{
GPIOx->BSRR |=GPIO_pin;
}//這里的gpio_pin前面除錯總出現沒有定義的錯誤提示,不知道哪里問題,后來把這里的都重寫了后又會提示其他地方的問題
uj5u.com熱心網友回復:
stm32f10x_gpio.c 是否包含檔案?uj5u.com熱心網友回復:
uj5u.com熱心網友回復:
現在就是不明白提示的錯誤怎么來的,查網咯說是呼叫的東西定義問題,但看著該有的都有啊uj5u.com熱心網友回復:
需要包含函式宣告的.h 檔案,或者extern 也行,就是找不到函式定義了。uj5u.com熱心網友回復:
warning: #223-D: function "GPIO_ResetBits" declared implicitlyGPIO_ResetBits(GPIOC,GPIO_Pin_6);
宣告GPIO_ResetBits函式的的.h 檔案沒有include進來
uj5u.com熱心網友回復:
宣告GPIO_ResetBits函式的.h 檔案stm32f10x_gpio.h已經包含到main中;void GPIO_Setbits(GPIO_TypeDef *GPIOx,uint16_t GPIO_pin);
void GPIO_Resetbits(GPIO_TypeDef *GPIOx,uint16_t GPIO_pin);這兩句就是在stm32f10x_GPIO.h中 GPIO_ResetBits和GPIO_setBits定義
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/32249.html
標籤:單片機/工控
下一篇:手機通過藍牙與藍牙單片機通信問題
