找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4555|回復(fù): 2
打印 上一主題 下一主題
收起左側(cè)

iccavr 編譯出了問題。。幫忙解決一下啊。。代碼在下面。。

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:44410 發(fā)表于 2012-9-5 11:32 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式

目的:將8個led燈分成兩組,這兩組輪流點亮
程序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++)
   ;
  }  
  }
}


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

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:45216 發(fā)表于 2012-10-4 02:30 | 只看該作者

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

回復(fù)

使用道具 舉報

板凳
ID:60635 發(fā)表于 2014-4-26 13:32 | 只看該作者
#define uint unsigned int
#define uchar unsigned char
改成typedef unsigned int uint;
      typedef unsigned char uchar;
試試
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表