Skip to content
Snippets Groups Projects
Commit 67135fef authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispiele 22.11.2021

parent 85278ae8
No related branches found
No related tags found
No related merge requests found
#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;
}
.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
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
#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;
}
.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
File added
File added
File added
File added
20211122/test.png

178 B

#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 };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment