標(biāo)題: iccavr 編譯出了問題。。幫忙解決一下啊。。代碼在下面。。 [打印本頁]

作者: _Jsky    時(shí)間: 2012-9-5 11:32
標(biāo)題: iccavr 編譯出了問題。。幫忙解決一下啊。。代碼在下面。。

目的:將8個(gè)led燈分成兩組,這兩組輪流點(diǎn)亮
程序1:
#include<iom128v.h>
#include<macros.h>
#define uint unsigned int
#define uchar unsigned char

void delay(uint del)
{
   uint i,j;
  for(i=0;i<del;i++)
   for(j=0;j<1241;j++)
  ;
 
}
void main()
{
  
 
  DDRA=0xff;
  PORTA=0xf0;
  while(1)
  {
     
    DDRE=DDRE|BIT(2);
  PORTE=PORTE|BIT(2);
   DDRA=0xff;
    PORTA=~PORTA;
  delay(1000); //延遲1s 
  }
}


程序2:
#include<iom128v.h>
#include<macros.h>
#define uint unsigned int
#define uchar unsigned char

void main()
{
  DDRA=0xff;
  PORTA=0xf0;
  while(1)
  {
     
  uint i,j;
    DDRE=DDRE|BIT(2);
  PORTE=PORTE|BIT(2);
   DDRA=0xff;
    PORTA=~PORTA;
  for(i=0;i<1000;i++)           //延遲1s
  {
   for(j=0;j<1241;j++)
   ;
  }  
  }
}


第二個(gè)程序可以實(shí)現(xiàn),第一個(gè)卻不能實(shí)現(xiàn),為什么呢?


作者: x594008    時(shí)間: 2012-10-4 02:30

LZ用studio單步調(diào)試一下不就知道問題出在哪里了。


作者: liuqing    時(shí)間: 2014-4-26 13:32
#define uint unsigned int
#define uchar unsigned char
改成typedef unsigned int uint;
      typedef unsigned char uchar;
試試




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1