找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

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

各位大神哪錯(cuò)了,測(cè)速的

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:198151 發(fā)表于 2017-5-8 15:25 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include"reg51.h"  
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
#define out P0
uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x01};
int i=0;
void main(void)
{
  int j;
  TMOD=0x15;
  TH0=0;
  TH00=0;
  TH1=0x3C;
  TL1=0xB0;                                                                                               
  TR0=1;
  TR1=1;
  IE=0x88;
    while(1)
    {
      P2=0x00;
       out=seg[i/100];
      P2=0x02;
      for(j=0;j<100;j++);
      P2=0x00;
      out=seg[i%100/10];
      P2=0x04;
      for(j=0;j<100;j++);
      P2=0x00;
      out=seg[i%10];
      P2=0x08;
      for(j=0;j<100;j++);
      }
}
void Timerl_ISR() interrupt3
{
  static char j=0;
  TH1=0x3C;
  TL1=0xB0;
  if( ++j==20)
  {
    j=0;
    i=(TH0<<8)|TH00;
    TH0=0;
    TL0=0;
   }
}

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

使用道具 舉報(bào)

沙發(fā)
ID:193350 發(fā)表于 2017-5-8 16:09 | 只看該作者
TH00=0;, i=(TH0<<8)|TH00; 中的TH00是啥玩意? T0計(jì)數(shù)器應(yīng)該是TH0,和TL0。測(cè)速的應(yīng)該還要加上與時(shí)間的計(jì)算,比如s/m,  km/h等。
回復(fù)

使用道具 舉報(bào)

板凳
ID:170270 發(fā)表于 2017-5-8 17:20 | 只看該作者
你的把問題說出來啊。。,F(xiàn)象啥的。。
回復(fù)

使用道具 舉報(bào)

地板
ID:148552 發(fā)表于 2017-5-8 17:37 | 只看該作者
#include"reg51.h"  
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
#define out P0
uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x01};
int i=0;
void main(void)
{
  int j;
  TMOD=0x15;
  TH0=0;
  TH0=0;
  TH1=0x3C;
  TL1=0xB0;                                                                                                
  TR0=1;
  TR1=1;
  IE=0x88;
    while(1)
    {
      P2=0x00;
       out=seg[i/100];
      P2=0x02;
      for(j=0;j<100;j++);
      P2=0x00;
      out=seg[i%100/10];
      P2=0x04;
      for(j=0;j<100;j++);
      P2=0x00;
      out=seg[i%10];
      P2=0x08;
      for(j=0;j<100;j++);
      }
}
void Timerl_ISR() interrupt 3
{
  static char j=0;
  TH1=0x3C;
  TL1=0xB0;
  if( ++j==20)
  {
    j=0;
    i=(TH0<<8)|TH0;
    TH0=0;
    TL0=0;
   }
}


幫你改好了
主要兩個(gè)地方錯(cuò)了
1.TH0你寫成了TH00
2.intrrupt(空格)3
回復(fù)

使用道具 舉報(bào)

5#
ID:198318 發(fā)表于 2017-5-8 20:36 來自手機(jī) | 只看該作者
你像風(fēng)兒來了 發(fā)表于 2017-5-8 17:37
#include"reg51.h"  
#include"intrins.h"
#define uchar unsigned char

大神,能幫忙幫我寫下5個(gè)數(shù)組比較大小的程序嗎?用for循環(huán)和if來實(shí)現(xiàn)的,數(shù)組為unsigned char可以,謝謝!
回復(fù)

使用道具 舉報(bào)

6#
ID:191024 發(fā)表于 2017-5-8 22:21 | 只看該作者
1.TH0你寫成了TH00   2.intrrupt(空格)3
回復(fù)

使用道具 舉報(bào)

7#
ID:189602 發(fā)表于 2017-5-9 13:33 | 只看該作者
TH0,和TL0。測(cè)速的應(yīng)該還要加上與時(shí)間的計(jì)算
回復(fù)

使用道具 舉報(bào)

8#
ID:168857 發(fā)表于 2017-5-9 15:40 | 只看該作者
現(xiàn)象說一下撒
回復(fù)

使用道具 舉報(bào)

9#
ID:198707 發(fā)表于 2017-5-9 16:42 | 只看該作者
說一下現(xiàn)象
回復(fù)

使用道具 舉報(bào)

10#
ID:116042 發(fā)表于 2017-5-9 17:07 | 只看該作者
說具體的哎
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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