打印

STM32F103报错提示--请教

[复制链接]
1697|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dc42733255|  楼主 | 2018-11-13 01:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
初学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







相关帖子

沙发
xyz549040622| | 2018-11-13 07:48 | 只看该作者
使用自己的头文件,干嘛不用官方的呀?

使用特权

评论回复
板凳
dc42733255|  楼主 | 2018-11-13 08:18 | 只看该作者
练练手吧!虽然官方有库文件,但是自己学习哈!还是可以灵活运用啥

使用特权

评论回复
地板
dc42733255|  楼主 | 2018-11-13 08:20 | 只看该作者
谢谢!大家!问题找到了!总线基地址宏定义括号输入法不对!我复制上来都变成其他字符了!修改后!问题解决

使用特权

评论回复
5
czwfcxu| | 2018-11-13 08:46 | 只看该作者
非常好的资料!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:学无止境

12

主题

101

帖子

0

粉丝