Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PIOB_PER *((volatile int*) 0xfffff400)
- #define PIOB_PDR *((volatile int*) 0xfffff404)
- #define PIOB_PSR *((volatile int*) 0xfffff408)
- #define PIOB_OER *((volatile int*) 0xfffff410)
- #define PIOB_ODR *((volatile int*) 0xfffff414)
- #define PIOB_OSR *((volatile int*) 0xfffff418)
- #define PIOB_SODR *((volatile int*) 0xfffff430)
- #define PIOB_CODR *((volatile int*) 0xfffff434)
- #define PIOB_ODSR *((volatile int*) 0xfffff438)
- #define LED0 1<<20
- #define LED1 1<<21
- #define LED2 1<<22
- #define LED3 1<<23
- #define LED4 1<<24
- #define LED5 1<<25
- #define LED6 1<<26
- #define LED7 1<<27
- #define LED_ENABLE 1<<16
- #define LED_DISP10 1<<30
- #define LED_DISP01 1<<28
- #define LED_DISP_ENABLE 1<<31
- #define DIGIT_0 LED0|LED1|LED2|LED4|LED5|LED7
- #define DIGIT_1 LED2|LED4
- #define DIGIT_2 LED0|LED1|LED4|LED5|LED6
- #define DIGIT_3 LED1|LED2|LED4|LED5|LED6
- #define DIGIT_4 LED2|LED4|LED6|LED7
- #define DIGIT_5 LED1|LED2|LED5|LED6|LED7
- #define DIGIT_6 LED0|LED1|LED2|LED5|LED6|LED7
- #define DIGIT_7 LED2|LED4|LED5
- #define DIGIT_8 LED0|LED1|LED2|LED4|LED5|LED6|LED7
- #define DIGIT_9 LED1|LED2|LED4|LED5|LED6|LED7
- #define DOT LED3
- #define DZIESIATKI(dec) (dec/10)
- #define JEDNOSCI(dec) (dec%10)
- void dbgu_print_ascii(const char* a){}
- void sleep(volatile int value){
- volatile int delay_counter = 0;
- for(delay_counter = 0; delay_counter<2000*value; delay_counter++);
- }
- void stop(){
- while(1){}
- }
- void init(){
- PIOB_PER = LED0|LED1|LED2|LED3|LED4|LED5|LED6|LED7|LED_DISP_ENABLE|LED_DISP01|LED_DISP10;
- PIOB_OER = LED0|LED1|LED2|LED3|LED4|LED5|LED6|LED7|LED_DISP_ENABLE|LED_DISP01|LED_DISP10;
- PIOB_CODR = LED0|LED1|LED2|LED3|LED4|LED5|LED6|LED7|LED_DISP_ENABLE|LED_DISP01|LED_DISP10;
- PIOB_SODR = LED_ENABLE;
- }
- int main(){
- volatile int number_counter;
- /*volatile int disp_numb = 0;*/
- volatile int numb_01;
- volatile int numb_10;
- volatile int digits[10] = {DIGIT_0,DIGIT_1,DIGIT_2,DIGIT_3,DIGIT_4,DIGIT_5,DIGIT_6,DIGIT_7,DIGIT_8,DIGIT_9};
- init();
- while(1)
- {
- for(number_counter = 0 ; number_counter<99 ; number_counter++){
- numb_01 = JEDNOSCI(number_counter);
- numb_10 = DZIESIATKI(number_counter);
- PIOB_SODR = LED_DISP01;
- PIOB_SODR = digits[numb_01];
- sleep(10);
- PIOB_CODR = digits[numb_01];
- PIOB_CODR = LED_DISP01;
- PIOB_SODR = LED_DISP10;
- PIOB_SODR = digits[numb_10];
- sleep(10);
- PIOB_CODR = digits[numb_10];
- PIOB_CODR = LED_DISP10;
- }
- /*
- for(led_counter = LED0; led_counter<LED7; led_counter=led_counter<<1)
- {
- PIOB_SODR = led_counter;
- sleep(DELAY);
- PIOB_CODR = led_counter;
- }
- for(led_counter = LED7; led_counter>LED0; led_counter=led_counter>>1)
- {
- PIOB_SODR = led_counter;
- sleep(DELAY);
- PIOB_CODR = led_counter;
- }
- */
- }
- stop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement