diff --git a/20211122/blink-10.c b/20211122/blink-10.c new file mode 100644 index 0000000000000000000000000000000000000000..6c36fbe183bb4c68bb0ae757145dd96897106dd9 --- /dev/null +++ b/20211122/blink-10.c @@ -0,0 +1,31 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +#define F_CPU 16000000l +#include <util/delay.h> + +volatile uint8_t key_pressed = 0; + +ISR (INT0_vect) /* PD2 */ +{ + key_pressed = 1; +} + +int main (void) +{ + cli (); + EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */ + EIMSK = 1 << INT0; /* INT0 einschalten */ + sei (); + DDRD = 0xfb; /* binär: 1111 1011 */ + PORTD = 0x44; /* binär: 0100 0100 */ + while (1) + { + while (!key_pressed) + ; /* just wait */ + PORTD ^= 0x40; + key_pressed = 0; + } + return 0; +} diff --git a/20211122/blink-10.s b/20211122/blink-10.s new file mode 100644 index 0000000000000000000000000000000000000000..b77f3989646f63d842f03582b278c2b2b8937ca4 --- /dev/null +++ b/20211122/blink-10.s @@ -0,0 +1,75 @@ + .file "blink-10.c" +__SP_H__ = 0x3e +__SP_L__ = 0x3d +__SREG__ = 0x3f +__tmp_reg__ = 0 +__zero_reg__ = 1 + .text +.global __vector_1 + .type __vector_1, @function +__vector_1: + push r1 + push r0 + in r0,__SREG__ + push r0 + clr __zero_reg__ + push r24 +/* prologue: Signal */ +/* frame size = 0 */ +/* stack size = 4 */ +.L__stack_usage = 4 + ldi r24,lo8(1) + sts key_pressed,r24 +/* epilogue start */ + pop r24 + pop r0 + out __SREG__,r0 + pop r0 + pop r1 + reti + .size __vector_1, .-__vector_1 + .section .text.startup,"ax",@progbits +.global main + .type main, @function +main: +/* prologue: function */ +/* frame size = 0 */ +/* stack size = 0 */ +.L__stack_usage = 0 +/* #APP */ + ; 17 "blink-10.c" 1 + cli + ; 0 "" 2 +/* #NOAPP */ + ldi r24,lo8(3) + sts 105,r24 + ldi r24,lo8(1) + out 0x1d,r24 +/* #APP */ + ; 20 "blink-10.c" 1 + sei + ; 0 "" 2 +/* #NOAPP */ + ldi r24,lo8(-5) + out 0xa,r24 + ldi r24,lo8(68) + out 0xb,r24 + ldi r25,lo8(64) +.L3: + lds r24,key_pressed + tst r24 + breq .L3 + in r24,0xb + eor r24,r25 + out 0xb,r24 + sts key_pressed,__zero_reg__ + rjmp .L3 + .size main, .-main +.global key_pressed + .section .bss + .type key_pressed, @object + .size key_pressed, 1 +key_pressed: + .zero 1 + .ident "GCC: (GNU) 5.4.0" +.global __do_clear_bss diff --git a/20211122/blink-11.c b/20211122/blink-11.c new file mode 100644 index 0000000000000000000000000000000000000000..72020dc5c582d1ce19e4efd8a079818760e89f27 --- /dev/null +++ b/20211122/blink-11.c @@ -0,0 +1,32 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +#define F_CPU 16000000l +#include <util/delay.h> + +volatile uint8_t key_pressed = 0; + +ISR (INT0_vect) /* PD2 */ +{ + key_pressed = 1; +} + +int main (void) +{ + cli (); + EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */ + EIMSK = 1 << INT0; /* INT0 einschalten */ + sei (); + DDRD = 0xfb; /* binär: 1111 1011 */ + PORTD = 0x44; /* binär: 0100 0100 */ + while (1) + { + while (!key_pressed) + ; /* just wait */ + _delay_ms (1); + PORTD ^= 0x40; + key_pressed = 0; + } + return 0; +} diff --git a/20211122/blink-4a.c b/20211122/blink-4a.c new file mode 100644 index 0000000000000000000000000000000000000000..9f98b66c38a49151f36f0d00faad69d74b434350 --- /dev/null +++ b/20211122/blink-4a.c @@ -0,0 +1,20 @@ +#include <avr/io.h> + +#define F_CPU 16000000 +#include <util/delay.h> + +int main (void) +{ /* binär: 0000 0001 */ + DDRD = 0x01; /* ^ Input */ + PORTD = 0x03; /* ^ Ouptut */ + /* binär: 0000 0011 */ + /* ^ PORT für Input setzen: internen Pull-Up aktivieren */ + while (1) + { + while (PIND & 0x02) /* binär: 0000 0010; Taste gedrückt --> PIN geht auf 0 */ + ; /* just wait */ /* nicht gedrückt --> über Pull-Up auf 1 */ + PORTD ^= 0x01; + _delay_ms (200); + } + return 0; +} diff --git a/20211122/blink-5.c b/20211122/blink-5.c new file mode 100644 index 0000000000000000000000000000000000000000..bb755f0de02d3e224909f1d2a37789f3c14a0f03 --- /dev/null +++ b/20211122/blink-5.c @@ -0,0 +1,19 @@ +#include <avr/io.h> +#include <avr/interrupt.h> + +ISR (TIMER0_COMPB_vect) +{ + PORTD ^= 0x40; +} + +int main (void) +{ + cli (); + TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */ + TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */ + sei (); + DDRD = 0xfd; /* binär: 1111 1101 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20211122/blink-5a.c b/20211122/blink-5a.c new file mode 100644 index 0000000000000000000000000000000000000000..8b1ad3d5429781697646f54fccb915d4dfa96924 --- /dev/null +++ b/20211122/blink-5a.c @@ -0,0 +1,20 @@ +#include <avr/io.h> +#include <avr/interrupt.h> + +ISR (TIMER0_COMPB_vect) +{ + PORTD ^= 0x40; +} + +int main (void) +{ + cli (); + CLKPR = (1 << CLKPCE) | (1 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); /* Prescaler: 256 */ + TCCR0B = (1 << CS02) | (0 << CS01) | (1 << CS00); /* Takt vom Prescaler durch 1024 dividieren */ + TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */ + sei (); + DDRD = 0xfd; /* binär: 1111 1101 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20211122/blink-5b.c b/20211122/blink-5b.c new file mode 100644 index 0000000000000000000000000000000000000000..6e76778fb44e93c91e6346d43bd3410581dbe6ed --- /dev/null +++ b/20211122/blink-5b.c @@ -0,0 +1,26 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +ISR (TIMER0_COMPB_vect) +{ + static uint8_t counter = 0; + if (counter++ >= 61) + { + PORTD ^= 0x40; + counter = 0; + } +} + +int main (void) +{ + cli (); + CLKPR = (1 << CLKPCE) | (1 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); /* Prescaler: 256 */ + TCCR0B = (1 << CS02) | (0 << CS01) | (1 << CS00); /* Takt vom Prescaler durch 1024 dividieren */ + TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */ + sei (); + DDRD = 0xfd; /* binär: 1111 1101 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20211122/blink-6.c b/20211122/blink-6.c new file mode 100644 index 0000000000000000000000000000000000000000..651ab6e4ac926242337a0520c11f2bbd935bdd22 --- /dev/null +++ b/20211122/blink-6.c @@ -0,0 +1,22 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +ISR (TIMER0_COMPB_vect) +{ + static uint8_t counter = 0; + if (counter++ == 0) + PORTD ^= 0x40; +} + +int main (void) +{ + cli (); + TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */ + TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */ + sei (); + DDRD = 0xfd; /* binär: 1111 1101 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20211122/blink-7.c b/20211122/blink-7.c new file mode 100644 index 0000000000000000000000000000000000000000..7ed39822752f61b636f001b77eb3742a57e953a9 --- /dev/null +++ b/20211122/blink-7.c @@ -0,0 +1,20 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +ISR (INT0_vect) /* PD2 */ +{ + PORTD ^= 0x40; +} + +int main (void) +{ + cli (); + EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */ + EIMSK = 1 << INT0; /* INT0 einschalten */ + sei (); + DDRD = 0xfb; /* binär: 1111 1011 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20211122/blink-7a.c b/20211122/blink-7a.c new file mode 100644 index 0000000000000000000000000000000000000000..c7a5b3c7b649b95a39cae67c52bcb199a281beec --- /dev/null +++ b/20211122/blink-7a.c @@ -0,0 +1,20 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +ISR (INT0_vect) /* PD2 */ +{ + PORTD ^= 0x40; +} + +int main (void) +{ + cli (); + EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */ + EIMSK = 1 << INT0; /* INT0 einschalten */ + sei (); + DDRD = 0xfb; /* binär: 1111 1011 */ + PORTD = 0x44; /* binär: 0100 0100 --> internen Pull-Up einschalten */ + while (1); + return 0; +} diff --git a/20211122/blink-8.c b/20211122/blink-8.c new file mode 100644 index 0000000000000000000000000000000000000000..aba94f07176a75656619d1ba09e83093cbc66c89 --- /dev/null +++ b/20211122/blink-8.c @@ -0,0 +1,20 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +ISR (INT0_vect) /* PD2 */ +{ + PORTD ^= 0x40; +} + +int main (void) +{ + cli (); + EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */ + EIMSK = 1 << INT0; /* INT0 einschalten */ + sei (); + DDRD = 0xff; /* binär: 1111 1111 */ + PORTD = 0x40; /* binär: 0100 0000 */ + while (1); + return 0; +} diff --git a/20211122/blink-9.c b/20211122/blink-9.c new file mode 100644 index 0000000000000000000000000000000000000000..486b7a2d07ea524e709560a627b4121ead7ed332 --- /dev/null +++ b/20211122/blink-9.c @@ -0,0 +1,31 @@ +#include <avr/io.h> +#include <avr/interrupt.h> +#include <stdint.h> + +#define F_CPU 16000000l +#include <util/delay.h> + +uint8_t key_pressed = 0; + +ISR (INT0_vect) /* PD2 */ +{ + key_pressed = 1; +} + +int main (void) +{ + cli (); + EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */ + EIMSK = 1 << INT0; /* INT0 einschalten */ + sei (); + DDRD = 0xfb; /* binär: 1111 1011 */ + PORTD = 0x44; /* binär: 0100 0100 */ + while (1) + { + while (!key_pressed) + ; /* just wait */ + PORTD ^= 0x40; + key_pressed = 0; + } + return 0; +} diff --git a/20211122/blink-9.s b/20211122/blink-9.s new file mode 100644 index 0000000000000000000000000000000000000000..82e900d919212d857c79b51e071b1a13babbfc75 --- /dev/null +++ b/20211122/blink-9.s @@ -0,0 +1,78 @@ + .file "blink-9.c" +__SP_H__ = 0x3e +__SP_L__ = 0x3d +__SREG__ = 0x3f +__tmp_reg__ = 0 +__zero_reg__ = 1 + .text +.global __vector_1 + .type __vector_1, @function +__vector_1: + push r1 + push r0 + in r0,__SREG__ + push r0 + clr __zero_reg__ + push r24 +/* prologue: Signal */ +/* frame size = 0 */ +/* stack size = 4 */ +.L__stack_usage = 4 + ldi r24,lo8(1) + sts key_pressed,r24 +/* epilogue start */ + pop r24 + pop r0 + out __SREG__,r0 + pop r0 + pop r1 + reti + .size __vector_1, .-__vector_1 + .section .text.startup,"ax",@progbits +.global main + .type main, @function +main: +/* prologue: function */ +/* frame size = 0 */ +/* stack size = 0 */ +.L__stack_usage = 0 +/* #APP */ + ; 17 "blink-9.c" 1 + cli + ; 0 "" 2 +/* #NOAPP */ + ldi r24,lo8(3) + sts 105,r24 + ldi r24,lo8(1) + out 0x1d,r24 +/* #APP */ + ; 20 "blink-9.c" 1 + sei + ; 0 "" 2 +/* #NOAPP */ + ldi r24,lo8(-5) + out 0xa,r24 + ldi r24,lo8(68) + out 0xb,r24 + ldi r25,lo8(64) +.L4: + lds r24,key_pressed + cpse r24,__zero_reg__ + rjmp .L7 +.L6: + rjmp .L6 +.L7: + in r24,0xb + eor r24,r25 + out 0xb,r24 + sts key_pressed,__zero_reg__ + rjmp .L4 + .size main, .-main +.global key_pressed + .section .bss + .type key_pressed, @object + .size key_pressed, 1 +key_pressed: + .zero 1 + .ident "GCC: (GNU) 5.4.0" +.global __do_clear_bss diff --git a/20211122/pull-up-pull-down.xcf.gz b/20211122/pull-up-pull-down.xcf.gz new file mode 100644 index 0000000000000000000000000000000000000000..8924a4bb61806f77202cc0d48fe6a62c6a7add75 Binary files /dev/null and b/20211122/pull-up-pull-down.xcf.gz differ diff --git a/20211122/test-2.pbm b/20211122/test-2.pbm new file mode 100644 index 0000000000000000000000000000000000000000..279da480f55e1dea8182dc6aaa493a1063f2f4bb Binary files /dev/null and b/20211122/test-2.pbm differ diff --git a/20211122/test-3.pbm b/20211122/test-3.pbm new file mode 100644 index 0000000000000000000000000000000000000000..f7895d98dfee7281f173ade62c1bf585bfac9ab2 Binary files /dev/null and b/20211122/test-3.pbm differ diff --git a/20211122/test.pbm b/20211122/test.pbm new file mode 100644 index 0000000000000000000000000000000000000000..2196f5cf811f0705aa4324f82088418694246002 Binary files /dev/null and b/20211122/test.pbm differ diff --git a/20211122/test.png b/20211122/test.png new file mode 100644 index 0000000000000000000000000000000000000000..1480054357897b1588fe228d7e10de08c9ffae32 Binary files /dev/null and b/20211122/test.png differ diff --git a/20211122/test.xbm b/20211122/test.xbm new file mode 100644 index 0000000000000000000000000000000000000000..874d1b8d757c202277041237b4198a89bc7bb18e --- /dev/null +++ b/20211122/test.xbm @@ -0,0 +1,5 @@ +#define test_width 9 +#define test_height 8 +static unsigned char test_bits[] = { + 0x00, 0x00, 0x44, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x82, 0x00, + 0x7c, 0x00, 0x00, 0x00 };