Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Projekt_nr1.h"
- #include "HardDef.h"
- uint32_t lastLetter=0;
- int main (void)
- {
- uint32_t i;
- DDR(A)=0xF0;
- DDR(C)=0xF0 | (1<<SEG_DIG1_PIN) | (1<<SEG_DIG2_PIN);
- PORTA=(uint8_t) (SEG_LITERA_0);
- //DDRD = 0xB0; //PORTD is output (PORTD ustawiony jako wyjściowy)
- TCNT1 = 0xF0BD; //Timer/Counter1 - look at the page 108 (patrz strona 108 dokumentacji)
- TCCR1A = 0x00; //Timer/Counter1 Control Register A - page 104 (patrz strona 104 dokumentacji)
- TCCR1B = (1 << CS10) | (1 << CS12); //Timer/Counter1 Control Register B - page 107 (patrz strona 107 dokumentacji, ustaw preskaler na clk/1024)
- TIMSK = (1 << TOIE1); //imer/Counter Interrupt Mask Register - page 109 (patrz strona 109 dokumentacji, ustaw overflow interrupt enable)
- sei(); //global interrupts are enabled (globalne odblokowanie przerwań (równoznaczne z ustawieniem bitu I w rejestrze SREG))
- //PORTD = ; //reset PORT D outputs
- //char red=0xef;
- //green=0xf7;
- //blue=0xfd;
- //uint32_t arr[3]={0xef,0xdf,0x7f};
- for(;;)
- {
- //for(i=0;i<3;i++)
- //{
- //PORTD = arr[i]; //turn on the LED (włącz diodę LED)
- //_delay_ms(1); //delay - use "for" or _delay_ms() (opóźnienie (np. pętla for lub funkcja biblioteczna _delay_ms (poszukaj w plikach xxxxxx.h))
- //PORTD = 0xff; //turn off the LED (wyłącz diodę LED)
- //_delay_ms(20); //delay - use "for" or _delay_ms() (opóźnienie (np. pętla for lub funkcja biblioteczna _delay_ms (poszukaj w plikach xxxxxx.h))
- //}
- }
- return 0;
- }
- //ISR (SIG_OVERFLOW1)
- ISR (TIMER1_OVF_vect)
- {
- uint8_t arr[3]={(uint8_t) (SEG_LITERA_F),(uint8_t) (SEG_LITERA_E),(uint8_t) (SEG_LITERA_0),(uint8_t) (SEG_LITERA_C),(uint8_t) (SEG_LITERA_8),(uint8_t) (SEG_LITERA_A),(uint8_t) (SEG_LITERA_9),(uint8_t) (SEG_LITERA_8)};
- DDR(C)=0xF0 | (1<<SEG_DIG1_PIN) | (1<<SEG_DIG2_PIN);
- if(PORTA != 0xFF)
- {
- PORTA=arr[2];
- }
- else
- {
- PORTA=arr[2];
- if(lastLetter<2)
- lastLetter++;
- else
- lastLetter=0;
- }
- TCNT1 = 0xF0BD;
- //_delay_ms(1000);
- //PORTD ^= 0x10;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement