void sci3_put (BYTE d) { BYTE i; while (TxFifo.ctr >= sizeof(TxFifo.buff)) ; i = TxFifo.wp; TxFifo.buff[i++] = d; TxFifo.wp = i % sizeof(TxFifo.buff); set_imask_ccr(1); TxFifo.ctr++; SCI3.SCR3.BIT.TIE = 1; set_imask_ccr(0); }
BYTE sci3_get (void) { BYTE d, i; while (RxFifo.ctr == 0) ; i = RxFifo.rp; d = RxFifo.buff[i++]; RxFifo.rp = i % sizeof(RxFifo.buff); set_imask_ccr(1); RxFifo.ctr--; set_imask_ccr(0); return d; }
__entry(vect=0) void PowerON_Reset(void) { set_imask_ccr(1); _INITSCT(); // _CALL_INIT(); // Remove the comment when you use global class object // _INIT_IOLIB(); // Remove the comment when you use SIM I/O // errno=0; // Remove the comment when you use errno // srand(1); // Remove the comment when you use rand() // _s1ptr=NULL; // Remove the comment when you use strtok() HardwareSetup(); // Remove the comment when you use Hardware Setup set_imask_ccr(0); main(); // _CLOSEALL(); // Remove the comment when you use SIM I/O // _CALL_END(); // Remove the comment when you use global class object sleep(); }
__entry(vect=0) void PowerON_Reset(void) { set_imask_ccr((_UBYTE)1); _INITSCT(); // _CALL_INIT(); // Remove the comment when you use global class object // _INIT_IOLIB(); // Enable I/O in the application(both SIM I/O and hardware I/O) // errno=0; // Remove the comment when you use errno // srand((_UINT)1); // Remove the comment when you use rand() // _s1ptr=NULL; // Remove the comment when you use strtok() // HardwareSetup(); // Remove the comment when you use Hardware Setup set_imask_ccr((_UBYTE)0); main(); // _CLOSEALL(); // Close I/O in the application(both SIM I/O andhardware I/O) // _CALL_END(); // Remove the comment when you use global class object sleep(); }
int bitin(void){ set_imask_ccr(1);// 割り込み禁止 TESTPIN = 0; /*1bitサイクルの計算のためのピン出力*/ for(kbit = 0 ; kbit < ONE_BIT_CYCLE ; kbit++){ if(FX_RXD != oldstate){ oldstate = FX_RXD; TESTPIN = 1; delay_us_rx(800); //delay_us_rx(1800);//430//元800 return 0; // state changed } } TESTPIN = 1; //delay_us_rx(345);//元100,82 delay_us_rx(30);//82 return 1; // state did not change }
//----------------------------------------------------------------------// void ini_pp(void) { portmr1 =0x08; //0b00001000; // TXD2 PORT1 =0x98; //0b10011000; portur1=0x00; //0b00000000; PORT2 =0x00; //0b00000000; portmr5 =0x00; //0b00000000; //为普通IO PORT5 =0xc0; //0b11000000; portur5=0x00; //0b00000000; PORT7 =0x16; //0b00010110; PORT8 =0x07; //0b00000111; emi_p(); //TIMERV初始化 //计数模式,水位处理 // TV.TCNTV=0; // TV.TCRV0.BYTE=0x05; //0b00000101 //外部脉冲--计数模式 //TIMERV初始化 //输出2.5K频率 驱动蜂鸣器 TV.TCNTV=0; TV.TCRV0.BYTE=0x0b; //0b00001011; //与A匹配 计数器清0 输入脉冲为1/64振荡频率 // TV.TCRV1.BIT.ICKS=1; TV.TCORA=0xFF; //2.5K比较常数 TV.TCORB=0xFF; //在50%时与B比较匹配, 则获得了50%占空比 /* //TIMERV初始化 //定时1毫秒中断 TV.TCNTV=0; TV.TCRV0.BYTE=0x4a; //01001010 与A匹配中断, 且清0 TV.TCSRV.BYTE=0x10; //00010000 TV.TCRV1.BYTE=0xe3; //11100011 TV.TCORA=250; */ //TIMERW初始化 //定时1毫秒,用于显示扫描和定时计时 TW.GRA=0xffff; TW.GRB=0xffff; TW.GRC=0xffff; TW.GRD=0xffff; TW.TCNT=57536; //1毫秒 //25536; //5毫秒 TW.TIOR0.BYTE=0x88; //0b10001000; TW.TIOR1.BYTE=0x88; //0b10001000; TW.TMRW.BYTE=0xc8; //0b11001000; TW.TCRW.BYTE=0x80; //0b10000000; TW.TSRW.BYTE=0x70; //0b01110000 TW.TIERW.BYTE=0xf0; //0b11110000; TW.TMRW.BIT.CTS=1; //START /* //TIMERW初始化 //外部脉冲测水位 TW.GRA=0xffff; TW.GRB=0xffff; TW.GRC=0xffff; TW.GRD=0xffff; TW.TCNT=0; // TW.TIOR0.BYTE=0x88; //10001000; TW.TIOR1.BYTE=0x88; //0b10001000; TW.TMRW.BYTE=0xc8; //0b11001000; TW.TCRW.BYTE=0x40; //0b01000000; //外部脉冲 TW.TSRW.BYTE=0x70; //0b01110000 TW.TIERW.BYTE=0x70; //0b01110000; TW.TMRW.BIT.CTS=1; //START */ //ADC初始化 AD.ADCSR.BYTE=0x03; //00000011 单次模式 4通道 /* //SCI--2 初始化 //9600BPS 1个起始 1个停止 无校验 SCI3_2.SCR3.BYTE=0x00; SCI3_2.SMR.BYTE=0x00; //00000000 1 开始 1结束 8数据 内部1:1 无校验 SCI3_2.BRR=25; //9600BPS delayus(120); SCI3_2.SSR.BYTE=(SCI3_2.SSR.BYTE|0x80)&0x80; SCI3_2.SCR3.BYTE=0x50; //接收允许 发送禁止 接收中断允许 发送中断禁止 */ //WDT初始化 //WDT时间为120毫秒 WDT.TMWD.BYTE =0x0e; //0b00001110; //时间常数 WDT.TCSRWD.BIT.B4WI=0; WDT.TCSRWD.BIT.TCSRWE=1; WDT.TCSRWD.BIT.WDON=1; //WDT开启 WDT.TCSRWD.BIT.TCSRWE=0; WDT.TCSRWD.BIT.B4WI=0; //中断初始化 // IRQ0中断 其它关闭 // IENR1.BYTE=0x01; //0b00000001; IRQ3 disable IRQ0 ENABLE // CCR.BIT.I=0; //总中断允许 set_imask_ccr(0); }