热度 15
2010-12-22 11:52
1250 次阅读|
1 个评论
#include static volatile int table ={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xd8,0x80, 0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x7f,0xbf,0x89,0xff}; volatile unsigned char data; #define PORTAIT(adr,bit) ((unsigned)(adr)*8+(bit)) static bit LOCK @ PORTAIT(PORTA,5); void SPIINT() { PIR1=0; SSPCON=0X30; SSPSTAT=0XC0; TRISC=0X00; } void initial() { TRISA=0X00; INTCON=0X00; LOCK=0; } void SPILED(int data) { SSPBUF=data; do {;} while(SSPIF==0); SSPIF=0; } void main() { unsigned int i; initial(); SPIINT(); for(i=5;i0;i--) { data=table ; SPILED(data); } LOCK=1; }