QQ截圖20181218041101.jpg (530.73 KB, 下載次數: 67)
下載附件
2018-12-18 04:21 上傳
- #include <iom16v.h>
- #define uchar unsigned char
- #define uint unsigned int
- const uchar SEG_CODE[] =
- {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x00};
- int main()
- {
- uchar LastKey = 0xff;
-
- DDRA = 0xff;
-
- DDRB = 0xff;
-
- DDRC = 0xff; PORTC = 0xff;
-
- DDRD = 0x00; PORTD = 0xff;
-
- TCCR1B = BIT(ICNC1) | BIT(ICES1);
-
- sei();
-
- while(1)
-
- {
-
- if( LastKey != PINC)
-
- {
- TIMSK = BIT(TICIE1);
-
- TCCR1B |= 0x01;
-
- LastKey = PINC;
-
- }
-
- Show_FRQ_ON_DSY();
-
- }
- }
- ISR (TIMER1_CAPT_vect)
- {
-
- uchar i;
-
- if(CAPi == 0)CAPi = ICR1;
-
- else
-
- {
- CAPj = ICR1 - CAPi;
-
- CAPj = 1000000/CAPj;
-
- TIMSK = 0;
-
- TCCR1B &= 0xfc;
-
- for(i = 3;i != 0xff;i--)
-
- {
-
- Display_Buffer[i] = CAPj % 10;
-
- CAPj /= 10;
-
- }
-
- TCNT1 = CAPi = CAPj =0;
-
- }
-
- }
復制代碼
|