Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include "Projekt_nr1.h"
  2. #include "HardDef.h"
  3. uint32_t lastLetter=0;
  4. int main (void)
  5. {
  6. uint32_t i;
  7. DDR(A)=0xF0;
  8. DDR(C)=0xF0 | (1<<SEG_DIG1_PIN) | (1<<SEG_DIG2_PIN);
  9. PORTA=(uint8_t) (SEG_LITERA_0);
  10. //DDRD = 0xB0; //PORTD is output (PORTD ustawiony jako wyjściowy)
  11.  
  12. TCNT1 = 0xF0BD; //Timer/Counter1 - look at the page 108 (patrz strona 108 dokumentacji)
  13. TCCR1A = 0x00; //Timer/Counter1 Control Register A - page 104 (patrz strona 104 dokumentacji)
  14. TCCR1B = (1 << CS10) | (1 << CS12); //Timer/Counter1 Control Register B - page 107 (patrz strona 107 dokumentacji, ustaw preskaler na clk/1024)
  15. TIMSK = (1 << TOIE1); //imer/Counter Interrupt Mask Register - page 109 (patrz strona 109 dokumentacji, ustaw overflow interrupt enable)
  16.  
  17. sei(); //global interrupts are enabled (globalne odblokowanie przerwań (równoznaczne z ustawieniem bitu I w rejestrze SREG))
  18.  
  19. //PORTD = ; //reset PORT D outputs
  20. //char red=0xef;
  21. //green=0xf7;
  22. //blue=0xfd;
  23.  
  24. //uint32_t arr[3]={0xef,0xdf,0x7f};
  25. for(;;)
  26. {
  27. //for(i=0;i<3;i++)
  28. //{
  29.  
  30. //PORTD = arr[i]; //turn on the LED (włącz diodę LED)
  31. //_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))
  32. //PORTD = 0xff; //turn off the LED (wyłącz diodę LED)
  33. //_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))
  34. //}
  35. }
  36.  
  37. return 0;
  38.  
  39. }
  40.  
  41.  
  42.  
  43. //ISR (SIG_OVERFLOW1)
  44. ISR (TIMER1_OVF_vect)
  45. {
  46. 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)};
  47. DDR(C)=0xF0 | (1<<SEG_DIG1_PIN) | (1<<SEG_DIG2_PIN);
  48. if(PORTA != 0xFF)
  49. {
  50.  
  51. PORTA=arr[2];
  52. }
  53. else
  54. {
  55. PORTA=arr[2];
  56. if(lastLetter<2)
  57. lastLetter++;
  58. else
  59. lastLetter=0;
  60. }
  61. TCNT1 = 0xF0BD;
  62. //_delay_ms(1000);
  63. //PORTD ^= 0x10;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement