Re: [問題] 8051 按鈕控制問題

作者: WolfLord (呆呆小狼￾ ￾ N￾ ￾ )   2013-08-23 21:59:48
#define CRYSTALFREQ 12000000
#define INSFREQ (CRYSTALFREQ/12)
#define TIMERFREQ (CRYSTALFREQ/12)
#define _BASETICK 1000
#define __FREQBASE__ (65536-((TIMERFREQ/_BASETICK)-10))
#define __VTH (__FREQBASE__/256)
#define __VTL (__FREQBASE__%256)
#define intINT0 0
#define intT0 1
#define intINT1 2
#define intT1 3
#define intUART1 4
#define intUART 4
#define intINT2 6
sbit out=P0^0;
sbit Key1=P1^0;
sbit Key2=P2^1;
unsigned long acttimer;
unsigned char key1cnt;
unsigned char key2cnt;
bit hold;
bit vout;
void _T0ISR(void) interrupt intT0{
TR0=0;TH0=__VTH;TL0=__VTL;TR0=1;TF0=0;
if(acttimer>0){acttimer
作者: victim0130 (Maxwell)   2013-08-23 23:36:00
W大程式功力實在令人佩服...小弟還得思考箇中邏輯原本今天有用goto寫出來,但goto似乎不要常用比較好!?
作者: ksmrt0123 (ksmrt)   2013-08-24 01:18:00
真是恐怖的coding style... 面試八成被打槍吧
作者: victim0130 (Maxwell)   2013-08-24 02:14:00
謝謝W大提供code...但的確要自己想過才會變成自己的!另想請問那寫法讓我感覺像是PIC的語法!?(疑惑中)
作者: WolfLord (呆呆小狼￾ ￾ N￾ ￾ )   2013-08-24 02:27:00
這不是PIC語法,這是ANSI C的STYTLE不過那個bit 跟 sbit是Keil獨有的
作者: victim0130 (Maxwell)   2013-08-24 02:32:00
瞭解!因為之前看蠻多PIC範例程式有用W大Stytle原來是ANSI C...受教了!! bit & sbit部分是知道的謝W大解惑... !!

Links booklink

Contact Us: admin [ a t ] ucptt.com