欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 新人求助mega16的程序怎么移植到128上 [打印本頁]

作者: Qabin    時間: 2020-4-11 15:19
標題: 新人求助mega16的程序怎么移植到128上
#include<iom16v.h>
#define uchar unsigned char
#define uint  unsigned int


uchar Table[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
uchar Data[4]={0,0,0,0};

void DelayMs(uint i)  //0.25ms
{uchar j;
for(;i!=0;i--)
  {for(j=250;j!=0;j--) {;}}
}

void Display(uchar *p) //間隔5ms顯示
{uchar i,sel=0x01;
for(i=0;i<4;i++)
  {PORTD=sel;
   PORTB=0xff-Table[p[i]];
   DelayMs(10);
   sel=sel<<1;
  }
}

uint ADC_Convert(void)
{uint temp1,temp2;
temp1=(uint)ADCL;
temp2=(uint)ADCH;
temp2=(temp2<<8)+temp1;
return(temp2);
}

void Process(uint i,uchar *p)
{p[0]=i/1000;
i=i%1000;
p[1]=i/100;
i=i%100;
p[2]=i/10;
i=i%10;
p[3]=i;
}

void main(void)
{uint i;
DDRA=0x00;                    //設置A口為不帶上拉輸入;
PORTA=0x00;
DDRB=0xff;                    //設置B口為推挽1輸出;
PORTB=0xff;
DDRD=0xff;                    //設置C口為推挽1輸出;
PORTD=0xff;
PORTB=0x00;                   //B口初始化輸出1;C口初始化輸出0;點亮全部數碼管;
PORTD=0xff;
ADMUX=0x01;                   //選擇第二通道ADC1;
ADCSR=0xe6;                   //125K轉換速率,自由轉換模式;啟動AD轉換器;
DelayMs(3000);                //延時待系統穩定;
while(1)
{i=ADC_Convert();
  Process(i,Data);
  Display(Data);
}
}


TIM截圖20200411151911.png (20.19 KB, 下載次數: 58)

proteus中16仿真

proteus中16仿真

作者: taotie    時間: 2020-4-11 18:20
對照兩個芯片管腳功能更改程序管腳,如:MEGA16 ADC是A端口,那MEGA128 ADC 是哪一個?




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