初学STM32f103,使用自己建的头文件,编译报错,网上查了很久也没有结果,以下是头文件以及点C文件和报错内容,请大家指点一下
头文件:
#define PERIPH_BASE ((unsigned int)0x400000000)
#define APB1PERIPH_BASE £¨PERIPH_BASE+0x00000000)
#define APB2PERIPH_BASE £¨PERIPH_BASE+0x00010000)
#define AHBPERIPH_BASE £¨PERIPH_BASE+0x00018000)
#define GPIOA_BASE (APB2PERIPH_BASE+0X0800)
#define GPIOB_BASE (APB2PERIPH_BASE+0X0C00)
#define GPIOC_BASE (APB2PERIPH_BASE+0X1000)
#define GPIOD_BASE (APB2PERIPH_BASE+0X1400)
#define GPIOA_CRL *(unsigned int *)(GPIOA_BASE+0X00)
#define GPIOA_CRH *(unsigned int *)(GPIOA_BASE+0X04)
#define GPIOA_IDR *(unsigned int *)(GPIOA_BASE+0X08)
#define GPIOA_0DR *(unsigned int *)(GPIOA_BASE+0X0C)
#define GPIOA_BSRR *(unsigned int *)(GPIOA_BASE+0X10)
#define GPIOA_BRR *(unsigned int *)(GPIOA_BASE+0X14)
#define GPIOA_LCKR *(unsigned int *)(GPIOA_BASE+0X18)
#define GPIOB_CRL *(unsigned int *)(GPIOB_BASE+0X00)
#define GPIOB_CRH *(unsigned int *)(GPIOB_BASE+0X04)
#define GPIOB_IDR *(unsigned int *)(GPIOB_BASE+0X08)
#define GPIOB_0DR *(unsigned int *)(GPIOB_BASE+0X0C)
#define GPIOB_BSRR *(unsigned int *)(GPIOB_BASE+0X10)
#define GPIOB_BRR *(unsigned int *)(GPIOB_BASE+0X14)
#define GPIOB_LCKR *(unsigned int *)(GPIOB_BASE+0X18)
#define GPIOC_CRL *(unsigned int *)(GPIOC_BASE+0X00)
#define GPIOC_CRH *(unsigned int *)(GPIOC_BASE+0X04)
#define GPIOC_IDR *(unsigned int *)(GPIOC_BASE+0X08)
#define GPIOC_ODR *(unsigned int *)(GPIOC_BASE+0X0C)
#define GPIOC_BSRR *(unsigned int *)(GPIOC_BASE+0X10)
#define GPIOC_BRR *(unsigned int *)(GPIOC_BASE+0X14)
#define GPIOC_LCKR *(unsigned int *)(GPIOC_BASE+0X18)
#define GPIOD_CRL *(unsigned int *)(GPIOD_BASE+0X00)
#define GPIOD_CRH *(unsigned int *)(GPIOD_BASE+0X04)
#define GPIOD_IDR *(unsigned int *)(GPIOD_BASE+0X08)
#define GPIOD_0DR *(unsigned int *)(GPIOD_BASE+0X0C)
#define GPIOD_BSRR *(unsigned int *)(GPIOD_BASE+0X10)
#define GPIOD_BRR *(unsigned int *)(GPIOD_BASE+0X14)
#define GPIOD_LCKR *(unsigned int *)(GPIOD_BASE+0X18)
.C文件
#include "stm32f10x.h"
int main(void)
{
*(unsigned int *)0x40021018 |=(1<<4);
GPIOC_CRL |=(1<<12);
GPIOC_ODR &=(~(1<<3)) ;
while(1)
{
//soft_delay(0x0007ffff) ;
GPIOC_0DR &=~(1<<3);
//soft_delay(0x0007ffff) ;
GPIOC_0DR |=(1<<3) ;
}
}
void SystemInit(void)
{
;
}
看了头文件没有什么错误,但是编译报以下错误:
*** Using Compiler 'V5.05 update 2 (build 169)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Target 1'
compiling main.c...
main.c(11): error: #7: unrecognized token
PIOC_CRL |=(1<<12);
main.c(11): error: #29: expected an expression
PIOC_CRL |=(1<<12);
main.c(11): error: #65: expected a ";"
PIOC_CRL |=(1<<12);
main.c(12): error: #7: unrecognized token
PIOC_ODR &=(~(1<<3)) ;
main.c(12): error: #29: expected an expression
PIOC_ODR &=(~(1<<3)) ;
main.c(12): error: #65: expected a ";"
PIOC_ODR &=(~(1<<3)) ;
main.c(16): error: #20: identifier "GPIOC_0DR" is undefined
GPIOC_0DR &=~(1<<3);
main.c: 0 warnings, 7 errors
compiling stm32f10x_gpio.c...
assembling startup_stm32f10x_hd.s...
".\Objects\reg-template.axf" - 7 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:01
|