Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "AT91SAM9263.h"
- #include "AT91SAM9263-EK.h"
- #define DELAY 62500 // to jest opoznienie z jakim bedzie sie wlaczal PIT
- #define A 1U<<25
- #define B 1U<<24
- #define C 1U<<22
- #define D 1U<<21
- #define E 1U<<20
- #define F 1U<<27
- #define G 1U<<26
- #define DP 1U<<23
- #define Q2 1U<<28
- #define S7_Q2 (A | B | C | D | E | F | G | DP)
- #define Q3 1U<<30
- #define S7 (A | B | C | D | E | F | G | DP | Q2 | Q3)
- const unsigned int number[10] = { //bajty do wlaczania numerkow
- A | B | C | D | E | F,
- B | C,
- A | B | G | E | D,
- A | B | G | C | D,
- F | G | C | B,
- A | F | G | C | D,
- A | F | E | G | C | D,
- A | B | C,
- A | B | C | D | E | F | G,
- A | F | B | G | C | D};
- void dbgu_print_ascii(const char* string){} //to gowno musi byc
- void wyswietl(int counter){
- volatile int index = 0;
- int count = 0;
- while(1){
- for(index = 0; index < 100; index++); //zwykly zwalniacz
- AT91C_BASE_PIOB->PIO_CODR = Q2; //uaktywniam jeden ekran
- AT91C_BASE_PIOB->PIO_CODR = S7_Q2;
- AT91C_BASE_PIOB->PIO_SODR = Q3 | number[counter/10]; //wlaczam odpowiednia cyfre
- for(index = 0; index < 100; index++);
- AT91C_BASE_PIOB->PIO_CODR = Q3; //uaktywniam druga strone ekranu
- AT91C_BASE_PIOB->PIO_CODR = S7_Q2;
- AT91C_BASE_PIOB->PIO_SODR = Q2 | number[counter%10]; //wlaczam odpowiednia cyfre
- if(AT91C_BASE_PITC->PITC_PISR){ //sprawdzenie wartosci PIT
- AT91C_BASE_PITC->PITC_PIVR; //odczytanie jej i wyzerowanie
- count++;
- if(count >= 100)
- return;
- }
- }
- }
- int main(){
- AT91C_BASE_PIOB->PIO_PER = S7;
- AT91C_BASE_PIOB->PIO_OER = S7;
- AT91C_BASE_PIOB->PIO_CODR = S7; //wlaczamy pio
- AT91C_BASE_PITC->PITC_PIMR = AT91C_PITC_PITEN | DELAY; //wlaczamy PIT i ustawiamy do jakiej wartosci ma obliczac
- AT91C_BASE_PITC->PITC_PIMR &= ~(AT91C_PITC_PITIEN); //dalsze wlaczenie PIT
- int counter = 0;
- while(1){
- wyswietl(counter);
- counter++;
- if(counter == 100)
- counter = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement