picc的源程序
#include<pic.h>#include"delay.h"
#define PORTBIT(adr, bit) ((unsigned)(&adr)*8+(bit))
static bit btnRtcc @ PORTBIT(PORTA,4);
void
DelayMs(unsigned char cnt)
{
#if XTAL_FREQ <= 2MHZ
do {
DelayUs(996);
} while(--cnt);
#endif
#if XTAL_FREQ > 2MHZ
unsigned char i;
do {
i = 4;
do {
DelayUs(200);
} while(--i);
} while(--cnt);
#endif
}
main(void)
{
unsigned char i,j;
static const unsigned char codeled =
{0x21,0x7D,0x32,0x38,0x6c,0x0A8,0x0A0,0x3D,0x20,0x28,
0x24,0x0E0,0x0A3,0x70,0x0A2,0xA6,0x00};
static const unsigned char codeledE =
{0x0,0x3,0x1,0x1,0x2,0x04,0x04,0x1,0x0,0x0,
0x0,0x06,0x04,0x3,0x04,0x4,0x00};
TRISA = 0x10; /* RA4=sw_RTCC input other bits output */
TRISB = 0x00; /* RB0=sw_INT input other bits output */
TRISC = 0; /* all bits output */
TRISD = 0;
TRISE = 0;
j = 0;
for(;;)
{
for(j=0;j<17;j++)
{
if(btnRtcc==0) break;
PORTA = codeled;
PORTB = codeled;
PORTC = codeled;
PORTD = codeled;
PORTE = codeledE;
DelayMs(200);/* output value of j */
}
for(j=0;j<17;j++)
{
PORTA = codeled;
PORTE=codeledE;
DelayMs(500);
}
for(j=0;j<17;j++)
{
PORTB = codeled;
DelayMs(500);
}
for(j=0;j<17;j++)
{
PORTC = codeled;
DelayMs(500);
}
for(j=0;j<17;j++)
{
PORTD = codeled;
DelayMs(500);
}
}
}
页:
[1]