Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- //#include <avr/iotn2313a.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- #define PCIE1 3
- uint8_t digits[] = {
- // 63,6,91,79,102,109,125,7,127,111};
- 119,66,93,94,106,62,63,82,127,126};
- volatile uint8_t loop;
- /*ISR(PCINT_A_vect, ISR_NAKED) {
- loop++; reti();
- }*/
- ISR(TIMER0_OVF_vect)
- {
- loop++;
- }
- /*ISR_ALIASOF(PCINT_A_vect));
- EMPTY_INTERRUPT(BADISR_vect);
- */
- void showDigit(uint8_t pos, uint8_t digit) {
- PORTB = digits[digit];
- PORTD = 0b11111 & ((uint8_t) ~_BV(pos));
- }
- void showNumber(uint8_t num) {
- uint8_t i = 0;
- do {
- //PORTB = digits[i];
- //PORTD = ((uint8_t) ~_BV(num % 10));
- showDigit(i++, num % 10);
- num /= 10;
- i++;
- } while (num > 0);
- }
- int main(void) {
- // ports output
- DDRB = 0xFF; // all pins
- DDRD = 0xFF; // are outputs
- DDRA = 0x01;
- //timer
- GTCCR = _BV(PSR10); // clear timer
- TCCR0B = _BV(CS00) | _BV(CS02); // prescaler 1/1024
- TIMSK = _BV(TOIE0); // timer overflow interrupt
- /*
- // interrupt
- GIMSK |= _BV(PCIE1); // pin change interrupt
- PCMSK1 |= _BV(PCINT9); // pin change for PINA2
- */
- sei(); // enable interrupts
- while (1) {
- //_delay_ms(500);
- showNumber(loop);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement