基于EM78P153S的流水燈#include"EM78x153xx.h"#define DISI() _asm{disi}#define ENI() _asm{eni}#define SLEP() _asm{slep}#define NOP() _asm{nop}#define WDTC() _asm{wdtc}typedef unsigned char uchar;typedef unsigned int uint;typedef unsigned short ushort;#define ledl PORT5#define ledh PORT6void delay(void){uchar i,j;for(j=0;j<200;j++)for(i=0;i<200;i++)NOP();}const ushort rundata[16]={0xfffe,0xfffc,0xfff8,0xfff0,0xffe0,0xffc0,0xff80,0xff00,0xfe00,0xfc00,0xf800,0xf000,0xe000,0xc000,0x8000,0x0000};void main(void){uchar i,j,k;uint run;WDTC();//清看門狗DISI();//禁止中斷STATUS=0X00;//清除狀態(tài)標(biāo)志位P5CR=0x00;//置P5為輸出口P6CR=0x00;//置P6為輸出口PDCR=0x00;//禁止P5,P6下拉ODCR=0x00;//禁止P6開漏PHCR=0x00;//禁止P6上拉for(;;)for(i=0,k=0;i<16;i++,k--){run=rundata[i];for(j=0;j>8);delay();}}}void _intcall interrupt(void) @ int {// Write your code (inline assembly or C) here//restore ACC,R3,R4_asm{reti //tell Compiler to recover common registers hereSWAP 0X1F ;restore ASWAPA 0X1F}}void _intcall interrupt_l(void) @ 0x08:low_int 0{_asm {//save A --> 0x1F MOV 0X1F,A ;backup A to 0x1F} }
評(píng)論