标题:调试出错,提示 error: #44: expression must have pointer type
取消只看楼主
zjfzdzc
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2020-4-29
结帖率:100%
 问题点数:0 回复次数:0 
调试出错,提示 error: #44: expression must have pointer type
调试结果,提示出错内容:*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Program Files\keil5\ARM\ARMCC\Bin'
Build target 'Target 1'
compiling main.c...
main.c(15): error:  #44: expression must have pointer type
  RCC->APB2ENR |=(1<<4);
main.c(16): error:  #44: expression must have pointer type
  GPIOC->CRL &=~(0x0F<<4*6);
main.c(17): error:  #44: expression must have pointer type
    GPIOC->CRL |=(1<<4*6);
main.c(18): error:  #44: expression must have pointer type
    GPIOC->ODR |=(1<<6);
main.c: 0 warnings, 4 errors
".\Objects\jcqld.axf" - 4 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01
以下自建头文件:
//#define RCC_APB2ENR *(unsigned int *)0x40021018
//#define GPIOD_CRL *(unsigned int *)0x40011400    //PD6清零
//#define GPIOD_ODR *(unsigned int *)0x4001140C    //PD6亮灯


//#define GPIOC_CRL *(unsigned int *)0x40011000   //PC6清零
//#define GPIOC_ODR *(unsigned int *)0x4001100C   //PC6亮灯

typedef unsigned int uint32_t;  //定义数据类型

#define PERIPH_BASE (unsigned int)0x40000000
#define APB2PERIPH_BASE (PERIPH_BASE+0x10000)
#define AHBPERIPH_BASE (PERIPH_BASE+0x20000)   //总线地址变量定义

#define GPIOC_BASE  (APB2PERIPH_BASE+0x1000)
//#define GPIOC_CRL *(unsigned int *)(GPIOC_BASE+0x00)
//#define GPIOC_ODR *(unsigned int *)(GPIOC_BASE+0x0C)   //端口C地址变量定义

typedef struct     //定义GPIO结构体
{
  uint32_t CRL;
    uint32_t CRH;
    uint32_t ODR;
}GPIO_TypeDef;

#define GPIOC (GPIO_TypeDef*)GPIOC_BASE  //定义GPIO基地址类型为GPIO

#define RCC_BASE (AHBPERIPH_BASE+0x1000)
//#define RCC_CR RCC_BASE
//#define RCC_APB2ENR  *(unsigned int *)(RCC_BASE+0x18)   //端口时钟地址变量定义

typedef struct  //定义RCC结构体
{
  uint32_t CR;
    uint32_t APB2ENR;
}RCC_TypeDef;

#define RCC (RCC_TypeDef*)RCC_BASE   //定义RCC基地址为RCC结构体


#include "stm32f10x_gpio.h"
//#include "stm32f10x.h"
主函数:
int main()
{
//RCC_APB2ENR |=(1<<5);
//GPIOD_CRL &=~(0x0F<<4*6);
//GPIOD_CRL |=(1<<24);
//GPIOD_ODR |=(1<<6);

//RCC_APB2ENR |=(1<<4);
//GPIOC_CRL &=~(0x0F<<4*6);
//GPIOC_CRL |=(1<<4*6);
//GPIOC_ODR |=(1<<6);
RCC->APB2ENR |=(1<<4);
GPIOC->CRL &=~(0x0F<<4*6);
  GPIOC->CRL |=(1<<4*6);
  GPIOC->ODR |=(1<<6);
   
}

和网上的视频教程编写一样,但一直有问题,用屏蔽掉的内容编译后可以正常输出,结构体调用
中不知道哪里有问题,说输出指向不对。
哪位能给说详细些,初学,有很多不明白。谢谢
搜索更多相关主题的帖子: define 定义 unsigned type int 
2020-05-05 17:02



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-501443-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.023828 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved