Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "mcc_generated_files/mcc.h"
- #include <xc.h>
- #include <stdint.h>
- // 0 1 2 3 4 5 6 7 8 9 A B C
- unsigned char led[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0xFF};
- unsigned char g=0,x=0,y=0,i,cnt=60;
- void disp(unsigned char num) {
- PORTC=led[num];
- if (num==0 || num==1||num==7){RA2=1;}
- else {RA2=0;}
- return;
- }
- void main(void) {
- OSCCON = 0x7A; // SCS INTOSC; SPLLEN disabled; IRCF 16MHz_HF;
- OSCTUNE = 0x00; // TUN 0;
- BORCON = 0x00; // SBOREN disabled; BORFS disabled;
- ANSELA=0x00;
- PORTA=0x00;
- TRISA = 0x01; // Port A is Digital Output RA0 input
- TRISC = 0; // Port C is Digital Output
- PORTC =0;
- RA1=0;
- while(g==0){
- y=cnt/10;
- x=cnt%10;
- for (i=0;i<50;i++){
- RA4=0;
- disp(x);
- __delay_ms(10);
- RA4=1;
- RA5=0;
- disp(y);
- __delay_ms(10);
- RA5=1;
- if (RA0==0){g=1;break;}
- }
- }
- while(cnt>0){
- y=cnt/10;
- x=cnt%10;
- for (i=0;i<20;i++){
- RA4=0;
- disp(x);
- __delay_ms(10);
- RA4=1;
- RA5=0;
- disp(y);
- __delay_ms(10);
- RA5=1;
- }
- cnt--;
- }
- RA1=1;
- while(1){
- for (i=0;i<50;i++){
- RA4=0;
- disp(0);
- __delay_ms(10);
- RA4=1;
- RA5=0;
- disp(0);
- __delay_ms(10);
- RA5=1;
- if (RA0==0){break;}
- }
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment