Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/interrupt.h>
- #include <avr/pgmspace.h>
- #define F_CPU 4000000UL
- #define GET_FAR_ADDRESS(var) \
- ({ \
- uint_farptr_t tmp; \
- \
- __asm__ __volatile__( \
- \
- "ldi %A0, lo8(%1)" "\n\t" \
- "ldi %B0, hi8(%1)" "\n\t" \
- "ldi %C0, hh8(%1)" "\n\t" \
- "clr %D0" "\n\t" \
- : \
- "=d" (tmp) \
- : \
- "p" (&(var)) \
- ); \
- tmp; \
- })
- const uint8_t tablica[] PROGMEM = {0x00, 0x01, 0xff, 0x03, 0xff, 0x05, 0xFF, 0xFF };
- void showROM(uint8_t *wsk)
- {
- uint8_t *tablica = wsk;
- uint8_t x,y;
- while(1)
- {
- x = pgm_read_byte_far(GET_FAR_ADDRESS(tablica));
- y = pgm_read_byte_far(GET_FAR_ADDRESS (++tablica));
- if(x==0xFF) {
- if(y==0xFF) {
- tablica=wsk;
- break;
- }
- }
- PORTB = ~x;
- }
- }
- int main(void)
- {
- DDRA = 0x00;// Port A - przyciski, wejściowy
- PORTA = 0xFF;
- DDRB = 0xFF; // Port B - diody, wyjściowy
- PORTB = 0x00;
- showROM( &tablica[0]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement