//****************************************************************************************** // PIC16F88 Sample Program // Project : // Program Name : // Programer : // Create date : Version 1.0 H24.06.05 // Replace date : // History : // Laungage : HI_TECH PICC C Laungage Version 9.83 //****************************************************************************************** // Description // OSC : External OSC 4MHz //****************************************************************************************** #include __CONFIG( FOSC_HS & WDTE_OFF & PWRTE_OFF & MCLRE_OFF & BOREN_OFF & LVP_OFF & CPD_OFF & WRT_OFF & DEBUG_OFF & CCPMX_RB0 & CP_OFF ); __CONFIG( FCMEN_OFF & IESO_OFF ); void timer(unsigned int); void watdsp(unsigned int); void setfnt(char); void outdsp(char ,unsigned int); unsigned char X1,X2,X3,X4,X5; int main(void) { TRISA=0x10; TRISB=0x00; while(1){ outdsp('0',2); outdsp('1',2); outdsp('2',2); outdsp('3',2); outdsp('4',2); outdsp('5',2); outdsp('6',2); outdsp('7',2); outdsp('8',2); outdsp('9',2); // outdsp('A',2); outdsp('B',2); outdsp('C',2); outdsp('D',2); outdsp('E',2); outdsp('F',2); outdsp('G',2); outdsp('H',2); outdsp('I',2); outdsp('J',2); outdsp('K',2); outdsp('L',2); outdsp('M',2); outdsp('N',2); outdsp('O',2); outdsp('P',2); outdsp('Q',2); outdsp('R',2); outdsp('S',2); outdsp('T',2); outdsp('U',2); outdsp('V',2); outdsp('W',2); outdsp('X',2); outdsp('Y',2); outdsp('Z',2); // outdsp('u',2); outdsp('d',2); outdsp('r',2); outdsp('l',2); outdsp(' ',2); outdsp('a',2); outdsp('e',2); } } //**************************************************************************** // Function Name : outdsp(c,n) about n[1/2 mS] // Title : // Input : // Output : // Description : OSC 4MHz //**************************************************************************** void outdsp(char c,unsigned int n) { setfnt(c); watdsp(n); } //**************************************************************************** // Function Name : watdsp(n) about n[1/2 mS] // Title : // Input : // Output : // Description : //**************************************************************************** void setfnt(char c) { // **************** // 0-9 // **************** if(c=='0'){ X1=0b00000000; X2=0b00111110; X3=0b01000001; X4=0b00111110; X5=0b00000000; return; } if(c=='1'){ X1=0b00000000; X2=0b01000010; X3=0b01111111; X4=0b01000000; X5=0b00000000; return; } if(c=='2'){ X1=0b01000010; X2=0b01000001; X3=0b01100001; X4=0b01010001; X5=0b01001110; return; } if(c=='3'){ X1=0b00100010; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00110110; return; } if(c=='4'){ X1=0b00111100; X2=0b00100010; X3=0b00100001; X4=0b01111111; X5=0b00100000; return; } if(c=='5'){ X1=0b01001111; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00110000; return; } if(c=='6'){ X1=0b00111110; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00110000; return; } if(c=='7'){ X1=0b00000001; X2=0b00000001; X3=0b01110001; X4=0b00001001; X5=0b00000111; return; } if(c=='8'){ X1=0b00110110; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00110110; return; } if(c=='9'){ X1=0b00100110; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00111110; return; } // **************** // A-Z // **************** if(c=='A'){ X1=0b01111100; X2=0b00010010; X3=0b00010001; X4=0b00010010; X5=0b01111100; return; } if(c=='B'){ X1=0b01111111; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00110110; return; } if(c=='C'){ X1=0b00111110; X2=0b01000001; X3=0b01000001; X4=0b01000001; X5=0b00100010; return; } if(c=='D'){ X1=0b01111111; X2=0b01000001; X3=0b01000001; X4=0b01000001; X5=0b00111110; return; } if(c=='E'){ X1=0b01111111; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b01001001; return; } if(c=='F'){ X1=0b01111111; X2=0b00001001; X3=0b00001001; X4=0b00001001; X5=0b00001001; return; } if(c=='G'){ X1=0b00111110; X2=0b01000001; X3=0b01001001; X4=0b01001001; X5=0b01111010; return; } if(c=='H'){ X1=0b01111111; X2=0b00001000; X3=0b00001000; X4=0b00001000; X5=0b01111111; return; } if(c=='I'){ X1=0b00000000; X2=0b01000001; X3=0b01111111; X4=0b01000001; X5=0b00000000; return; } if(c=='J'){ X1=0b00100000; X2=0b01000000; X3=0b01000000; X4=0b01000000; X5=0b00111111; return; } if(c=='K'){ X1=0b01111111; X2=0b00001000; X3=0b00010100; X4=0b00100010; X5=0b01000001; return; } if(c=='L'){ X1=0b01111111; X2=0b01000000; X3=0b01000000; X4=0b01000000; X5=0b01000000; return; } if(c=='M'){ X1=0b01111111; X2=0b00000010; X3=0b00011100; X4=0b00000010; X5=0b01111111; return; } if(c=='N'){ X1=0b01111111; X2=0b00000010; X3=0b00001000; X4=0b00100000; X5=0b01111111; return; } if(c=='O'){ X1=0b00111110; X2=0b01000001; X3=0b01000001; X4=0b01000001; X5=0b00111110; return; } if(c=='P'){ X1=0b01111111; X2=0b00001001; X3=0b00001001; X4=0b00001001; X5=0b00000110; return; } if(c=='Q'){ X1=0b00111110; X2=0b01000001; X3=0b01010001; X4=0b00111110; X5=0b01000000; return; } if(c=='R'){ X1=0b01111111; X2=0b00001001; X3=0b00011001; X4=0b00101001; X5=0b01000110; return; } if(c=='S'){ X1=0b00100110; X2=0b01001001; X3=0b01001001; X4=0b01001001; X5=0b00110010; return; } if(c=='T'){ X1=0b00000001; X2=0b00000001; X3=0b01111111; X4=0b00000001; X5=0b00000001; return; } if(c=='U'){ X1=0b00111111; X2=0b01000000; X3=0b01000000; X4=0b01000000; X5=0b00111111; return; } if(c=='V'){ X1=0b00011111; X2=0b00100000; X3=0b01000000; X4=0b00100000; X5=0b00011111; return; } if(c=='W'){ X1=0b00111111; X2=0b01000000; X3=0b00111111; X4=0b01000000; X5=0b00111111; return; } if(c=='X'){ X1=0b01000001; X2=0b00100010; X3=0b00011100; X4=0b00100010; X5=0b01000001; return; } if(c=='Y'){ X1=0b00000001; X2=0b00000100; X3=0b01110000; X4=0b00000100; X5=0b00000001; return; } if(c=='Z'){ X1=0b01100001; X2=0b01010001; X3=0b01001001; X4=0b01000101; X5=0b01000011; return; } // **************** // ELSE // **************** if(c==' '){ X1=0b00000000; X2=0b00000000; X3=0b00000000; X4=0b00000000; X5=0b00000000; return; } if(c=='u'){ X1=0b00000100; X2=0b00000010; X3=0b01111111; X4=0b00000010; X5=0b00000100; return; } if(c=='d'){ X1=0b00010000; X2=0b00100000; X3=0b01111111; X4=0b00100000; X5=0b00010000; return; } if(c=='r'){ X1=0b00001000; X2=0b01001001; X3=0b00101010; X4=0b00011100; X5=0b00001000; return; } if(c=='l'){ X1=0b00001000; X2=0b00011100; X3=0b00101010; X4=0b01001001; X5=0b00001000; return; } if(c=='a'){ X1=0b01111111; X2=0b01111111; X3=0b01111111; X4=0b01111111; X5=0b01111111; return; } X1=0b00000110; X2=0b00001001; X3=0b01110001; X4=0b00000001; X5=0b00000010; return; } //**************************************************************************** // Function Name : watdsp(n) about n[mS] // Title : // Input : // Output : // Description : //**************************************************************************** void watdsp(unsigned int n) { unsigned int lp,lp1; unsigned int Tw=4; // 1.Initialize PORTA=0; PORTB=0; // 2.Display for(lp=0;lp