#2
JabinZ2020-05-31 23:06
|
错误提示:
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);
}
///////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;
}