打印
[AVR单片机]

为什么指针在ICC AVR中不能用呢?

[复制链接]
1140|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zezy371|  楼主 | 2013-9-24 12:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
大家好,我在学习指针时为什么指针在ICC AVR中不能用呢?
#include <iom16v.h>
#include <macros.h>

typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long ulong;

const uchar liu_shui_deng[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};


void delay_ms(uint ms)
{
   uchar a,b;
   while(ms--)
   {
      for(b=10;b>0;b--)
      for(a=110;a>0;a--);
   }
}

void port_init(void)
{
   DDRD=0xff;
   PORTD=0x00;
}

void main(void)
{
   uchar *p;
   uchar i;
   while(1)
   {
      p=&liu_shui_deng;
      for(i=0;i<8;i++)
          {
             PORTD=*p;
                 p++;
                 delay_ms(200);

          }
          p-=1;
          for(i=0;i<8;i++)
          {
                 PORTD=*p;
                 p--;
                 delay_ms(200);
          }
   }
}

同样的程序在keil中能用

相关帖子

沙发
zezy371|  楼主 | 2013-9-24 13:27 | 只看该作者
发错了,是这样的
#include <iom16v.h>
#include <macros.h>

typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long ulong;

const uchar liu_shui_deng[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};


void delay_ms(uint ms)
{
   uchar a,b;
   while(ms--)
   {
      for(b=10;b>0;b--)
      for(a=110;a>0;a--);
   }
}

void port_init(void)
{
   DDRD=0xff;
   PORTD=0x00;
}
void main(void)
{
   uchar *p;
   uchar i;
   port_init();
   while(1)
   {
      p=&liu_shui_deng;
      for(i=0;i<8;i++)
          {
             PORTD=*p;
                 p++;
                 delay_ms(200);

          }
          p-=1;
          for(i=0;i<8;i++)
          {
                 PORTD=*p;
                 p--;
                 delay_ms(200);
          }
   }
}

使用特权

评论回复
板凳
huangxz| | 2013-9-24 23:14 | 只看该作者
本帖最后由 huangxz 于 2013-9-24 23:16 编辑

怎么个不能用****法.....

使用特权

评论回复
地板
huangxz| | 2013-9-24 23:15 | 只看该作者
方法的法都不能打?

使用特权

评论回复
5
qin552011373| | 2013-9-25 14:59 | 只看该作者
贴一下出错信息

使用特权

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

本版积分规则

27

主题

241

帖子

0

粉丝