Advertisement
Guest User

Sw

a guest
Jan 26th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "AT91SAM9263.h"
  2. #include "AT91SAM9263-EK.h"
  3.  
  4. #define DELAY 62500 //  to jest opoznienie z jakim bedzie sie wlaczal PIT
  5.  
  6. #define A   1U<<25
  7. #define B   1U<<24
  8. #define C   1U<<22
  9. #define D   1U<<21
  10. #define E   1U<<20
  11. #define F   1U<<27
  12. #define G   1U<<26
  13. #define DP  1U<<23
  14.  
  15. #define Q2  1U<<28
  16. #define S7_Q2   (A | B | C | D | E | F | G | DP)
  17. #define Q3  1U<<30
  18. #define S7  (A | B | C | D | E | F | G | DP | Q2 | Q3)
  19.  
  20.  
  21. const unsigned int number[10] = {       //bajty do wlaczania numerkow
  22. A | B | C | D | E | F,
  23. B | C,
  24. A | B | G | E | D,
  25. A | B | G | C | D,
  26. F | G | C | B,
  27. A | F | G | C | D,
  28. A | F | E | G | C | D,
  29. A | B | C,
  30. A | B | C | D | E | F | G,
  31. A | F | B | G | C | D};
  32.  
  33. void dbgu_print_ascii(const char* string){} //to gowno musi byc
  34.  
  35. void wyswietl(int counter){
  36.     volatile int index = 0;
  37.     int count = 0;
  38.     while(1){  
  39.         for(index = 0; index < 100; index++); //zwykly zwalniacz
  40.         AT91C_BASE_PIOB->PIO_CODR = Q2;     //uaktywniam jeden ekran
  41.         AT91C_BASE_PIOB->PIO_CODR = S7_Q2;
  42.         AT91C_BASE_PIOB->PIO_SODR = Q3 | number[counter/10];    //wlaczam odpowiednia cyfre
  43.         for(index = 0; index < 100; index++);
  44.         AT91C_BASE_PIOB->PIO_CODR = Q3;     //uaktywniam druga strone ekranu
  45.         AT91C_BASE_PIOB->PIO_CODR = S7_Q2;
  46.         AT91C_BASE_PIOB->PIO_SODR = Q2 | number[counter%10]; //wlaczam odpowiednia cyfre
  47.         if(AT91C_BASE_PITC->PITC_PISR){     //sprawdzenie wartosci PIT
  48.             AT91C_BASE_PITC->PITC_PIVR;     //odczytanie jej i wyzerowanie
  49.             count++;
  50.             if(count >= 100)
  51.                 return;
  52.         }
  53.     }
  54. }
  55.  
  56. int main(){
  57.     AT91C_BASE_PIOB->PIO_PER = S7;
  58.     AT91C_BASE_PIOB->PIO_OER = S7;
  59.     AT91C_BASE_PIOB->PIO_CODR = S7;     //wlaczamy pio
  60.    
  61.     AT91C_BASE_PITC->PITC_PIMR = AT91C_PITC_PITEN | DELAY;      //wlaczamy PIT i ustawiamy do jakiej wartosci ma obliczac
  62.     AT91C_BASE_PITC->PITC_PIMR &= ~(AT91C_PITC_PITIEN);         //dalsze wlaczenie PIT
  63.    
  64.     int counter = 0;
  65.     while(1){
  66.         wyswietl(counter);
  67.         counter++;
  68.         if(counter == 100)
  69.             counter = 0;
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement