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