P5 initial

This commit is contained in:
S170H
2024-01-20 22:27:43 +01:00
parent 237e085b51
commit 6655d01102
26 changed files with 1132 additions and 453 deletions

Binary file not shown.

34
Abgaben/P4/keys.c Normal file
View File

@@ -0,0 +1,34 @@
#include "keys.h"
void setupTimer0() {
// Configure Timer0 for CTC mode
TCCR0A |= (1 << WGM01); // Set Waveform Generation Mode bits for CTC
TCCR0B |= (1 << CS01) | (1 << CS00); // Set prescaler to 64
OCR0A = 249; // Set Output Compare Register to 249 for ~1ms interrupt
TIMSK0 |= (1 << OCIE0A); // Enable Timer0 Output Compare A Match interrupt
}
void setupRegisters(){
DDRD = 0xff; // Data direction register D (D0 -> D6) as output
// PORTD = 0xff; // setting bit for 7-segment show 0
// => spielt keine Rolle, wird von der while Schleife <20>bernommen
DDRB = 0x01; // Data direction register B (B0) as output and DDRB (B1, B2) as input
PORTB |= (1 << PINB1) | (1 << PINB2) ; // setting bit for teens B0=0 and SW1-2
// PINB=0 => start with LED3 (Einer)
// mit unserem Atmega nicht m<>glich, da keine PCINT8_vect und PCINT9_vect vorhanden
// DDRC = 0x00; // Data direction register C as input for SW1 and SW2
// PORTC |= (1<<PINC0) | (1<<PINC1); // settings pins for SW1 -> PINC0 and SW2 -> PINC1
cli(); // clear global interrupt flag: interrupts will be immediately disabled
PCICR |= 0x01; // Pin Change Interrupt Control Register: turn on PortB
PCMSK0 |= (1 << PINB1) | (1 << PINB2); // trigger interrupt when SW1 or SW2 is pressed
sei(); // set global interrupt enable
}
void init(){
setupTimer0();
setupRegisters();
}

12
Abgaben/P4/keys.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef KEYS_H_
#define KEYS_H_
#include <avr/io.h>
#include <avr/interrupt.h>
void setupTimer0();
void setupRegisters();
void init();
#endif /* KEYS_H_ */

12
Abgaben/P4/main.c Normal file
View File

@@ -0,0 +1,12 @@
#include "keys.h"
#include "sevenseg.h"
int main(void) {
init();
while(1) {
display();
}
}

71
Abgaben/P4/sevenseg.c Normal file
View File

@@ -0,0 +1,71 @@
#include "sevenseg.h"
//-Timer---------------------------------------
volatile uint32_t systemClock = 0;
ISR(TIMER0_COMPA_vect) {
systemClock++;
}
uint32_t getSystemClock(){
return systemClock;
}
void waitFor(uint32_t ms) {
uint32_t endTime = getSystemClock() + ms;
while (getSystemClock() != endTime);
}
//-Counter-------------------------------------
volatile int count = 0;
ISR(PCINT0_vect) { // every 10ms interrupt is triggered
if (!(PINB & (1<<PINB1))) { // count down => sw1 is pressed
if (count == 0) count = 100; // 100 - 1 = 99
count--;
}
if (!(PINB & (1<<PINB2))) { // count up => sw2 is pressed
if (count == 99) count = -1; // -1 + 1 = 0
count++;
}
}
//-Display--------------------------------------
void display() {
/*
logical 0: on
logical 1: off
.gfe dcba HEX int
0 : 1100 0000 = C0 192
1 : 1111 1001 = F9 249
2 : 1010 0100 = A4 164
3 : 1011 0000 = 30 48
4 : 1001 1001 = 99 153
5 : 1001 0010 = 92 146
6 : 1000 0010 = 82 130
7 : 1111 1000 = F8 248
8 : 1000 0000 = 80 128
9 : 1001 0000 = 90 144
*/
int numbersAsSegments[10] = { 192, 249, 164, 48, 153, 146, 130, 248, 128, 144 }; // display number from 0 to 9;
volatile int led_Einer = numbersAsSegments[(int) count % 10]; // Segmentanzeige f<>r Zehner
volatile int led_Zehner = numbersAsSegments[(int) (count - (count % 10)) / 10]; // Segmentanzeige f<>r Einer
PORTD = led_Einer;
//_delay_ms(10);
waitFor(10);
PORTB ^= (1 << PINB0);
PORTD = led_Zehner;
//_delay_ms(10);
waitFor(10);
PORTB ^= (1 << PINB0);
}

12
Abgaben/P4/sevenseg.h Normal file
View File

@@ -0,0 +1,12 @@
#ifndef SEVENSEG_H_
#define SEVENSEG_H_
#define F_CPU 16000000UL // 16MHz clock frequency
#include <util/delay.h>
#include <avr/interrupt.h>
#include "avr/io.h"
uint32_t getSystemClock();
void waitFor(uint32_t ms);
void display();
#endif /* SEVENSEG_H_ */

Binary file not shown.

Binary file not shown.

View File

@@ -1,43 +1,54 @@
:100000000C9434000C9451000C9451000C94670033 :100000000C9434000C9451000C9451000C94C400D6
:100010000C9451000C9451000C9451000C9451001C :100010000C9451000C9451000C9451000C9451001C
:100020000C9451000C9451000C9451000C9451000C :100020000C9451000C9451000C9451000C9451000C
:100030000C9451000C9451000C9451000C945100FC :100030000C9451000C9451000C947F000C945100CE
:100040000C9451000C9451000C9451000C945100EC :100040000C9451000C9451000C9451000C945100EC
:100050000C9451000C9451000C9451000C945100DC :100050000C9451000C9451000C9451000C945100DC
:100060000C9451000C94510011241FBECFEFD8E026 :100060000C9451000C94510011241FBECFEFD8E026
:10007000DEBFCDBF11E0A0E0B1E0E2E7F2E002C0F8 :10007000DEBFCDBF11E0A0E0B1E0EEE2F3E002C0F0
:1000800005900D92A431B107D9F721E0A4E1B1E0C8 :1000800005900D92A431B107D9F721E0A4E1B1E0C8
:1000900001C01D92A631B207E1F70E94A5000C94A1 :1000900001C01D92AA31B207E1F70E947A000C94C8
:1000A00037010C9400008FEF8AB981E084B985B1E3 :1000A00095010C94000084B5826084BD85B58360A1
:1000B000866085B9F894E8E6F0E08081816080830D :1000B00085BD89EF87BDEEE6F0E0808182608083B8
:1000C000EBE6F0E0808186608083789408951F924B :1000C00008958FEF8AB981E084B985B1866085B9DA
:1000D0000F920FB60F9211248F939F93199916C008 :1000D000F894E8E6F0E0808181608083EBE6F0E070
:1000E0008091140190911501892B31F484E690E000 :1000E000808186608083789408950E9453000E94E6
:1000F0009093150180931401809114019091150142 :1000F000610008950E9475000E940101FDCF1F92CA
:100100000197909315018093140118C01A9916C095 :100100000F920FB60F9211248F939F93AF93BF93CB
:1001100080911401909115018336910531F48FEF90 :100110008091160190911701A0911801B0911901D9
:100120009FEF909315018093140180911401909199 :100120000196A11DB11D8093160190931701A09314
:100130001501019690931501809314019F918F9161 :100130001801B0931901BF91AF919F918F910F90CA
:100140000F900FBE0F901F9018950E945300809142 :100140000FBE0F901F9018950F931F9300911601EB
:100150001401909115010E94AE00F9CF0F931F93E7 :10015000109117012091180130911901AB01BC01D8
:10016000CF93DF93CDB7DEB768970FB6F894DEBFB5 :10016000400F511F621F731F80911601909117015C
:100170000FBECDBF9C0184E1E0E0F1E0DE0111960D :10017000A0911801B091190184179507A607B70738
:1001800001900D928A95E1F70AE010E0C901B801EB :1001800099F71F910F9108951F920F920FB60F923A
:100190000E940F01FC01EE0FFF1F41E050E04C0FE9 :1001900011248F939F93199915C080911401909108
:1001A0005D1FE40FF51F408151815E8B4D8BF9017E :1001A0001501892B31F484E690E09093150180933A
:1001B000E81BF90BCF01B8010E940F01FB01EE0F04 :1001B00014018091140190911501019790931501FC
:1001C000FF1F41E050E04C0F5D1FE40FF51F8081E1 :1001C000809314011A9916C0809114019091150121
:1001D0009181988F8F8B8D899E898BB98FE39CE954 :1001D0008336910531F48FEF9FEF90931501809353
:1001E0000197F1F700C0000095B181E0982795B91B :1001E00014018091140190911501019690931501CD
:1001F0002F89388D2BB9EFE3FCE93197F1F700C077 :1001F000809314019F918F910F900FBE0F901F90CD
:10020000000095B1892785B968960FB6F894DEBFCE :1002000018951F93CF93DF93CDB7DEB768970FB6DE
:100210000FBECDBFDF91CF911F910F91089597FB36 :10021000F894DEBF0FBECDBF84E1E0E0F1E0DE0187
:10022000072E16F4009407D077FD09D00E94230111 :10022000119601900D928A95E1F7809114019091B9
:1002300007FC05D03EF4909581959F4F08957095E9 :1002300015012AE030E0B9010E946D01FC01EE0FCA
:1002400061957F4F0895AA1BBB1B51E107C0AA1FF0 :10024000FF1F41E050E04C0F5D1FE40FF51F808160
:10025000BB1FA617B70710F0A61BB70B881F991F67 :1002500091819E8B8D8BE0911401F091150180911D
:100260005A95A9F780959095BC01CD010895F89411 :10026000140190911501B9010E946D01AF01481B65
:02027000FFCFBE :10027000590BCA01B9010E946D01FB01EE0FFF1F6E
:10027200C000F900A4003000990092008200F8004A :1002800081E090E08C0F9D1FE80FF91F8081918124
:040282008000900068 :10029000988F8F8B8D899E898BB96AE070E080E0A2
:1002A00090E00E94A40085B111E0812785B98F8973
:1002B000988D8BB96AE070E080E090E00E94A40025
:1002C00085B1182715B968960FB6F894DEBF0FBE32
:1002D000CDBFDF91CF911F91089597FB072E16F4A4
:1002E000009407D077FD09D00E94810107FC05D05A
:1002F0003EF4909581959F4F0895709561957F4F3D
:100300000895AA1BBB1B51E107C0AA1FBB1FA6175C
:10031000B70710F0A61BB70B881F991F5A95A9F7AE
:0E03200080959095BC01CD010895F894FFCF13
:10032E00C000F900A4003000990092008200F8008D
:04033E0080009000AB
:00000001FF :00000001FF

View File

@@ -3,31 +3,31 @@ P4.elf: file format elf32-avr
Sections: Sections:
Idx Name Size VMA LMA File off Algn Idx Name Size VMA LMA File off Algn
0 .data 00000014 00800100 00000272 00000306 2**0 0 .data 00000014 00800100 0000032e 000003c2 2**0
CONTENTS, ALLOC, LOAD, DATA CONTENTS, ALLOC, LOAD, DATA
1 .text 00000272 00000000 00000000 00000094 2**1 1 .text 0000032e 00000000 00000000 00000094 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .bss 00000002 00800114 00800114 0000031a 2**0 2 .bss 00000006 00800114 00800114 000003d6 2**0
ALLOC ALLOC
3 .comment 00000030 00000000 00000000 0000031a 2**0 3 .comment 00000030 00000000 00000000 000003d6 2**0
CONTENTS, READONLY CONTENTS, READONLY
4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 0000034c 2**2 4 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 00000408 2**2
CONTENTS, READONLY CONTENTS, READONLY
5 .debug_aranges 00000068 00000000 00000000 0000038c 2**0 5 .debug_aranges 00000090 00000000 00000000 00000448 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
6 .debug_info 000008f2 00000000 00000000 000003f4 2**0 6 .debug_info 0000094d 00000000 00000000 000004d8 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
7 .debug_abbrev 00000797 00000000 00000000 00000ce6 2**0 7 .debug_abbrev 00000799 00000000 00000000 00000e25 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
8 .debug_line 00000448 00000000 00000000 0000147d 2**0 8 .debug_line 00000432 00000000 00000000 000015be 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
9 .debug_frame 000000ac 00000000 00000000 000018c8 2**2 9 .debug_frame 00000124 00000000 00000000 000019f0 2**2
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
10 .debug_str 0000041d 00000000 00000000 00001974 2**0 10 .debug_str 0000042d 00000000 00000000 00001b14 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
11 .debug_loc 00000170 00000000 00000000 00001d91 2**0 11 .debug_loc 0000012f 00000000 00000000 00001f41 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
12 .debug_ranges 00000038 00000000 00000000 00001f01 2**0 12 .debug_ranges 00000060 00000000 00000000 00002070 2**0
CONTENTS, READONLY, DEBUGGING CONTENTS, READONLY, DEBUGGING
Disassembly of section .text: Disassembly of section .text:
@@ -36,7 +36,7 @@ Disassembly of section .text:
0: 0c 94 34 00 jmp 0x68 ; 0x68 <__ctors_end> 0: 0c 94 34 00 jmp 0x68 ; 0x68 <__ctors_end>
4: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 4: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
8: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 8: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
c: 0c 94 67 00 jmp 0xce ; 0xce <__vector_3> c: 0c 94 c4 00 jmp 0x188 ; 0x188 <__vector_3>
10: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 10: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
14: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 14: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
18: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 18: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
@@ -47,7 +47,7 @@ Disassembly of section .text:
2c: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 2c: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
30: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 30: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
34: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 34: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
38: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 38: 0c 94 7f 00 jmp 0xfe ; 0xfe <__vector_14>
3c: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 3c: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
40: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 40: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
44: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt> 44: 0c 94 51 00 jmp 0xa2 ; 0xa2 <__bad_interrupt>
@@ -72,8 +72,8 @@ Disassembly of section .text:
74: 11 e0 ldi r17, 0x01 ; 1 74: 11 e0 ldi r17, 0x01 ; 1
76: a0 e0 ldi r26, 0x00 ; 0 76: a0 e0 ldi r26, 0x00 ; 0
78: b1 e0 ldi r27, 0x01 ; 1 78: b1 e0 ldi r27, 0x01 ; 1
7a: e2 e7 ldi r30, 0x72 ; 114 7a: ee e2 ldi r30, 0x2E ; 46
7c: f2 e0 ldi r31, 0x02 ; 2 7c: f3 e0 ldi r31, 0x03 ; 3
7e: 02 c0 rjmp .+4 ; 0x84 <__do_copy_data+0x10> 7e: 02 c0 rjmp .+4 ; 0x84 <__do_copy_data+0x10>
80: 05 90 lpm r0, Z+ 80: 05 90 lpm r0, Z+
82: 0d 92 st X+, r0 82: 0d 92 st X+, r0
@@ -91,315 +91,432 @@ Disassembly of section .text:
92: 1d 92 st X+, r1 92: 1d 92 st X+, r1
00000094 <.do_clear_bss_start>: 00000094 <.do_clear_bss_start>:
94: a6 31 cpi r26, 0x16 ; 22 94: aa 31 cpi r26, 0x1A ; 26
96: b2 07 cpc r27, r18 96: b2 07 cpc r27, r18
98: e1 f7 brne .-8 ; 0x92 <.do_clear_bss_loop> 98: e1 f7 brne .-8 ; 0x92 <.do_clear_bss_loop>
9a: 0e 94 a5 00 call 0x14a ; 0x14a <main> 9a: 0e 94 7a 00 call 0xf4 ; 0xf4 <main>
9e: 0c 94 37 01 jmp 0x26e ; 0x26e <_exit> 9e: 0c 94 95 01 jmp 0x32a ; 0x32a <_exit>
000000a2 <__bad_interrupt>: 000000a2 <__bad_interrupt>:
a2: 0c 94 00 00 jmp 0 ; 0x0 <__vectors> a2: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
000000a6 <init>: 000000a6 <setupTimer0>:
#include "keys.h" #include "keys.h"
void setupTimer0() {
void init(){ // Configure Timer0 for CTC mode
DDRD = 0xff; // Data direction register D (D0 -> D6) as output TCCR0A |= (1 << WGM01); // Set Waveform Generation Mode bits for CTC
a6: 8f ef ldi r24, 0xFF ; 255 a6: 84 b5 in r24, 0x24 ; 36
a8: 8a b9 out 0x0a, r24 ; 10 a8: 82 60 ori r24, 0x02 ; 2
// PORTD = 0xff; // setting bit for 7-segment show 0 aa: 84 bd out 0x24, r24 ; 36
// => spielt keine Rolle, wird von der while Schleife <20>bernommen TCCR0B |= (1 << CS01) | (1 << CS00); // Set prescaler to 64
ac: 85 b5 in r24, 0x25 ; 37
DDRB = 0x01; // Data direction register B (B0) as output and DDRB (B1, B2) as input ae: 83 60 ori r24, 0x03 ; 3
aa: 81 e0 ldi r24, 0x01 ; 1 b0: 85 bd out 0x25, r24 ; 37
ac: 84 b9 out 0x04, r24 ; 4 OCR0A = 249; // Set Output Compare Register to 249 for ~1ms interrupt
PORTB |= (1 << PINB1) | (1 << PINB2) ; // setting bit for teens and SW1-2 b2: 89 ef ldi r24, 0xF9 ; 249
ae: 85 b1 in r24, 0x05 ; 5 b4: 87 bd out 0x27, r24 ; 39
b0: 86 60 ori r24, 0x06 ; 6 TIMSK0 |= (1 << OCIE0A); // Enable Timer0 Output Compare A Match interrupt
b2: 85 b9 out 0x05, r24 ; 5 b6: ee e6 ldi r30, 0x6E ; 110
// mit unserem Atmega nicht m<>glich, da keine PCINT8_vect und PCINT9_vect vorhanden
// DDRC = 0x00; // Data direction register C as input for SW1 and SW2
// PORTC |= (1<<PINC0) | (1<<PINC1); // settings pins for SW1 -> PINC0 and SW2 -> PINC1
cli(); // clear global interrupt flag: interrupts will be immediately disabled
b4: f8 94 cli
PCICR |= 0x01; // Pin Change Interrupt Control Register: turn on PortB
b6: e8 e6 ldi r30, 0x68 ; 104
b8: f0 e0 ldi r31, 0x00 ; 0 b8: f0 e0 ldi r31, 0x00 ; 0
ba: 80 81 ld r24, Z ba: 80 81 ld r24, Z
bc: 81 60 ori r24, 0x01 ; 1 bc: 82 60 ori r24, 0x02 ; 2
be: 80 83 st Z, r24 be: 80 83 st Z, r24
PCMSK0 |= (1 << PINB1) | (1 << PINB2); // trigger interrupt when SW1 or SW2 is pressed c0: 08 95 ret
c0: eb e6 ldi r30, 0x6B ; 107
c2: f0 e0 ldi r31, 0x00 ; 0
c4: 80 81 ld r24, Z
c6: 86 60 ori r24, 0x06 ; 6
c8: 80 83 st Z, r24
sei(); // set global interrupt enable
ca: 78 94 sei
cc: 08 95 ret
000000ce <__vector_3>: 000000c2 <setupRegisters>:
}
void setupRegisters(){
DDRD = 0xff; // Data direction register D (D0 -> D6) as output
c2: 8f ef ldi r24, 0xFF ; 255
c4: 8a b9 out 0x0a, r24 ; 10
// PORTD = 0xff; // setting bit for 7-segment show 0
// => spielt keine Rolle, wird von der while Schleife <20>bernommen
DDRB = 0x01; // Data direction register B (B0) as output and DDRB (B1, B2) as input
c6: 81 e0 ldi r24, 0x01 ; 1
c8: 84 b9 out 0x04, r24 ; 4
PORTB |= (1 << PINB1) | (1 << PINB2) ; // setting bit for teens B0=0 and SW1-2
ca: 85 b1 in r24, 0x05 ; 5
cc: 86 60 ori r24, 0x06 ; 6
ce: 85 b9 out 0x05, r24 ; 5
// mit unserem Atmega nicht m<>glich, da keine PCINT8_vect und PCINT9_vect vorhanden
// DDRC = 0x00; // Data direction register C as input for SW1 and SW2
// PORTC |= (1<<PINC0) | (1<<PINC1); // settings pins for SW1 -> PINC0 and SW2 -> PINC1
cli(); // clear global interrupt flag: interrupts will be immediately disabled
d0: f8 94 cli
PCICR |= 0x01; // Pin Change Interrupt Control Register: turn on PortB
d2: e8 e6 ldi r30, 0x68 ; 104
d4: f0 e0 ldi r31, 0x00 ; 0
d6: 80 81 ld r24, Z
d8: 81 60 ori r24, 0x01 ; 1
da: 80 83 st Z, r24
PCMSK0 |= (1 << PINB1) | (1 << PINB2); // trigger interrupt when SW1 or SW2 is pressed
dc: eb e6 ldi r30, 0x6B ; 107
de: f0 e0 ldi r31, 0x00 ; 0
e0: 80 81 ld r24, Z
e2: 86 60 ori r24, 0x06 ; 6
e4: 80 83 st Z, r24
sei(); // set global interrupt enable
e6: 78 94 sei
e8: 08 95 ret
000000ea <init>:
}
void init(){
setupTimer0();
ea: 0e 94 53 00 call 0xa6 ; 0xa6 <setupTimer0>
setupRegisters();
ee: 0e 94 61 00 call 0xc2 ; 0xc2 <setupRegisters>
f2: 08 95 ret
000000f4 <main>:
#include "keys.h" #include "keys.h"
#include "sevenseg.h" #include "sevenseg.h"
int main(void) {
init();
f4: 0e 94 75 00 call 0xea ; 0xea <init>
while(1) {
display();
f8: 0e 94 01 01 call 0x202 ; 0x202 <display>
fc: fd cf rjmp .-6 ; 0xf8 <main+0x4>
000000fe <__vector_14>:
systemClock++;
}
uint32_t getSystemClock(){
return systemClock;
}
fe: 1f 92 push r1
100: 0f 92 push r0
102: 0f b6 in r0, 0x3f ; 63
104: 0f 92 push r0
106: 11 24 eor r1, r1
108: 8f 93 push r24
10a: 9f 93 push r25
10c: af 93 push r26
10e: bf 93 push r27
110: 80 91 16 01 lds r24, 0x0116 ; 0x800116 <systemClock>
114: 90 91 17 01 lds r25, 0x0117 ; 0x800117 <systemClock+0x1>
118: a0 91 18 01 lds r26, 0x0118 ; 0x800118 <systemClock+0x2>
11c: b0 91 19 01 lds r27, 0x0119 ; 0x800119 <systemClock+0x3>
120: 01 96 adiw r24, 0x01 ; 1
122: a1 1d adc r26, r1
124: b1 1d adc r27, r1
126: 80 93 16 01 sts 0x0116, r24 ; 0x800116 <systemClock>
12a: 90 93 17 01 sts 0x0117, r25 ; 0x800117 <systemClock+0x1>
12e: a0 93 18 01 sts 0x0118, r26 ; 0x800118 <systemClock+0x2>
132: b0 93 19 01 sts 0x0119, r27 ; 0x800119 <systemClock+0x3>
136: bf 91 pop r27
138: af 91 pop r26
13a: 9f 91 pop r25
13c: 8f 91 pop r24
13e: 0f 90 pop r0
140: 0f be out 0x3f, r0 ; 63
142: 0f 90 pop r0
144: 1f 90 pop r1
146: 18 95 reti
00000148 <waitFor>:
void waitFor(uint32_t ms) {
148: 0f 93 push r16
14a: 1f 93 push r17
ISR(TIMER0_COMPA_vect) {
systemClock++;
}
uint32_t getSystemClock(){
return systemClock;
14c: 00 91 16 01 lds r16, 0x0116 ; 0x800116 <systemClock>
150: 10 91 17 01 lds r17, 0x0117 ; 0x800117 <systemClock+0x1>
154: 20 91 18 01 lds r18, 0x0118 ; 0x800118 <systemClock+0x2>
158: 30 91 19 01 lds r19, 0x0119 ; 0x800119 <systemClock+0x3>
}
void waitFor(uint32_t ms) {
uint32_t endTime = getSystemClock() + ms;
15c: ab 01 movw r20, r22
15e: bc 01 movw r22, r24
160: 40 0f add r20, r16
162: 51 1f adc r21, r17
164: 62 1f adc r22, r18
166: 73 1f adc r23, r19
ISR(TIMER0_COMPA_vect) {
systemClock++;
}
uint32_t getSystemClock(){
return systemClock;
168: 80 91 16 01 lds r24, 0x0116 ; 0x800116 <systemClock>
16c: 90 91 17 01 lds r25, 0x0117 ; 0x800117 <systemClock+0x1>
170: a0 91 18 01 lds r26, 0x0118 ; 0x800118 <systemClock+0x2>
174: b0 91 19 01 lds r27, 0x0119 ; 0x800119 <systemClock+0x3>
}
void waitFor(uint32_t ms) {
uint32_t endTime = getSystemClock() + ms;
while (getSystemClock() != endTime);
178: 84 17 cp r24, r20
17a: 95 07 cpc r25, r21
17c: a6 07 cpc r26, r22
17e: b7 07 cpc r27, r23
180: 99 f7 brne .-26 ; 0x168 <waitFor+0x20>
}
182: 1f 91 pop r17
184: 0f 91 pop r16
186: 08 95 ret
00000188 <__vector_3>:
//-Counter-------------------------------------
volatile int count = 0; volatile int count = 0;
ISR(PCINT0_vect) { // every 10ms interrupt is triggered ISR(PCINT0_vect) { // every 10ms interrupt is triggered
ce: 1f 92 push r1 188: 1f 92 push r1
d0: 0f 92 push r0 18a: 0f 92 push r0
d2: 0f b6 in r0, 0x3f ; 63 18c: 0f b6 in r0, 0x3f ; 63
d4: 0f 92 push r0 18e: 0f 92 push r0
d6: 11 24 eor r1, r1 190: 11 24 eor r1, r1
d8: 8f 93 push r24 192: 8f 93 push r24
da: 9f 93 push r25 194: 9f 93 push r25
if (!(PINB & (1<<PINB1))) { // sw1 is pressed
dc: 19 99 sbic 0x03, 1 ; 3 if (!(PINB & (1<<PINB1))) { // count down => sw1 is pressed
de: 16 c0 rjmp .+44 ; 0x10c <__vector_3+0x3e> 196: 19 99 sbic 0x03, 1 ; 3
if (count == 0) { 198: 15 c0 rjmp .+42 ; 0x1c4 <__vector_3+0x3c>
e0: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end> if (count == 0) count = 100; // 100 - 1 = 99
e4: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1> 19a: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
e8: 89 2b or r24, r25 19e: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
ea: 31 f4 brne .+12 ; 0xf8 <__vector_3+0x2a> 1a2: 89 2b or r24, r25
count = 100; // 100 - 1 = 99 1a4: 31 f4 brne .+12 ; 0x1b2 <__vector_3+0x2a>
ec: 84 e6 ldi r24, 0x64 ; 100 1a6: 84 e6 ldi r24, 0x64 ; 100
ee: 90 e0 ldi r25, 0x00 ; 0 1a8: 90 e0 ldi r25, 0x00 ; 0
f0: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1> 1aa: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1>
f4: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end> 1ae: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end>
}
count--; count--;
f8: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end> 1b2: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
fc: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1> 1b6: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
100: 01 97 sbiw r24, 0x01 ; 1 1ba: 01 97 sbiw r24, 0x01 ; 1
102: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1> 1bc: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1>
106: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end> 1c0: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end>
10a: 18 c0 rjmp .+48 ; 0x13c <__vector_3+0x6e>
} }
else if (!(PINB & (1<<PINB2))) { // sw2 is pressed
10c: 1a 99 sbic 0x03, 2 ; 3 if (!(PINB & (1<<PINB2))) { // count up => sw2 is pressed
10e: 16 c0 rjmp .+44 ; 0x13c <__vector_3+0x6e> 1c4: 1a 99 sbic 0x03, 2 ; 3
if (count == 99) { 1c6: 16 c0 rjmp .+44 ; 0x1f4 <__vector_3+0x6c>
110: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end> if (count == 99) count = -1; // -1 + 1 = 0
114: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1> 1c8: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
118: 83 36 cpi r24, 0x63 ; 99 1cc: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
11a: 91 05 cpc r25, r1 1d0: 83 36 cpi r24, 0x63 ; 99
11c: 31 f4 brne .+12 ; 0x12a <__vector_3+0x5c> 1d2: 91 05 cpc r25, r1
count = -1; // -1 + 1 = 0 1d4: 31 f4 brne .+12 ; 0x1e2 <__vector_3+0x5a>
11e: 8f ef ldi r24, 0xFF ; 255 1d6: 8f ef ldi r24, 0xFF ; 255
120: 9f ef ldi r25, 0xFF ; 255 1d8: 9f ef ldi r25, 0xFF ; 255
122: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1> 1da: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1>
126: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end> 1de: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end>
}
count++; count++;
12a: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end> 1e2: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
12e: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1> 1e6: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
132: 01 96 adiw r24, 0x01 ; 1 1ea: 01 96 adiw r24, 0x01 ; 1
134: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1> 1ec: 90 93 15 01 sts 0x0115, r25 ; 0x800115 <__data_end+0x1>
138: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end> 1f0: 80 93 14 01 sts 0x0114, r24 ; 0x800114 <__data_end>
} }
} }
13c: 9f 91 pop r25 1f4: 9f 91 pop r25
13e: 8f 91 pop r24 1f6: 8f 91 pop r24
140: 0f 90 pop r0 1f8: 0f 90 pop r0
142: 0f be out 0x3f, r0 ; 63 1fa: 0f be out 0x3f, r0 ; 63
144: 0f 90 pop r0 1fc: 0f 90 pop r0
146: 1f 90 pop r1 1fe: 1f 90 pop r1
148: 18 95 reti 200: 18 95 reti
0000014a <main>: 00000202 <display>:
int main(void) { //-Display--------------------------------------
init();
14a: 0e 94 53 00 call 0xa6 ; 0xa6 <init>
while(1) {
display(count);
14e: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
152: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
156: 0e 94 ae 00 call 0x15c ; 0x15c <display>
15a: f9 cf rjmp .-14 ; 0x14e <main+0x4>
0000015c <display>: void display() {
#include "sevenseg.h" 202: 1f 93 push r17
204: cf 93 push r28
void display(int count) { 206: df 93 push r29
15c: 0f 93 push r16 208: cd b7 in r28, 0x3d ; 61
15e: 1f 93 push r17 20a: de b7 in r29, 0x3e ; 62
160: cf 93 push r28 20c: 68 97 sbiw r28, 0x18 ; 24
162: df 93 push r29 20e: 0f b6 in r0, 0x3f ; 63
164: cd b7 in r28, 0x3d ; 61 210: f8 94 cli
166: de b7 in r29, 0x3e ; 62 212: de bf out 0x3e, r29 ; 62
168: 68 97 sbiw r28, 0x18 ; 24 214: 0f be out 0x3f, r0 ; 63
16a: 0f b6 in r0, 0x3f ; 63 216: cd bf out 0x3d, r28 ; 61
16c: f8 94 cli
16e: de bf out 0x3e, r29 ; 62
170: 0f be out 0x3f, r0 ; 63
172: cd bf out 0x3d, r28 ; 61
174: 9c 01 movw r18, r24
7 : 1111 1000 = F8 248 7 : 1111 1000 = F8 248
8 : 1000 0000 = 80 128 8 : 1000 0000 = 80 128
9 : 1001 0000 = 90 144 9 : 1001 0000 = 90 144
*/ */
int numbersAsSegments[10] = { 192, 249, 164, 48, 153, 146, 130, 248, 128, 144 }; // display number from 0 to 9; int numbersAsSegments[10] = { 192, 249, 164, 48, 153, 146, 130, 248, 128, 144 }; // display number from 0 to 9;
176: 84 e1 ldi r24, 0x14 ; 20 218: 84 e1 ldi r24, 0x14 ; 20
178: e0 e0 ldi r30, 0x00 ; 0 21a: e0 e0 ldi r30, 0x00 ; 0
17a: f1 e0 ldi r31, 0x01 ; 1 21c: f1 e0 ldi r31, 0x01 ; 1
17c: de 01 movw r26, r28 21e: de 01 movw r26, r28
17e: 11 96 adiw r26, 0x01 ; 1 220: 11 96 adiw r26, 0x01 ; 1
180: 01 90 ld r0, Z+ 222: 01 90 ld r0, Z+
182: 0d 92 st X+, r0 224: 0d 92 st X+, r0
184: 8a 95 dec r24 226: 8a 95 dec r24
186: e1 f7 brne .-8 ; 0x180 <display+0x24> 228: e1 f7 brne .-8 ; 0x222 <display+0x20>
volatile int led_Einer = numbersAsSegments[(int) count % 10]; // Segmentanzeige f<>r Zehner volatile int led_Einer = numbersAsSegments[(int) count % 10]; // Segmentanzeige f<>r Zehner
188: 0a e0 ldi r16, 0x0A ; 10 22a: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
18a: 10 e0 ldi r17, 0x00 ; 0 22e: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
18c: c9 01 movw r24, r18 232: 2a e0 ldi r18, 0x0A ; 10
18e: b8 01 movw r22, r16 234: 30 e0 ldi r19, 0x00 ; 0
190: 0e 94 0f 01 call 0x21e ; 0x21e <__divmodhi4> 236: b9 01 movw r22, r18
194: fc 01 movw r30, r24 238: 0e 94 6d 01 call 0x2da ; 0x2da <__divmodhi4>
196: ee 0f add r30, r30 23c: fc 01 movw r30, r24
198: ff 1f adc r31, r31 23e: ee 0f add r30, r30
19a: 41 e0 ldi r20, 0x01 ; 1 240: ff 1f adc r31, r31
19c: 50 e0 ldi r21, 0x00 ; 0 242: 41 e0 ldi r20, 0x01 ; 1
19e: 4c 0f add r20, r28 244: 50 e0 ldi r21, 0x00 ; 0
1a0: 5d 1f adc r21, r29 246: 4c 0f add r20, r28
1a2: e4 0f add r30, r20 248: 5d 1f adc r21, r29
1a4: f5 1f adc r31, r21 24a: e4 0f add r30, r20
1a6: 40 81 ld r20, Z 24c: f5 1f adc r31, r21
1a8: 51 81 ldd r21, Z+1 ; 0x01 24e: 80 81 ld r24, Z
1aa: 5e 8b std Y+22, r21 ; 0x16 250: 91 81 ldd r25, Z+1 ; 0x01
1ac: 4d 8b std Y+21, r20 ; 0x15 252: 9e 8b std Y+22, r25 ; 0x16
254: 8d 8b std Y+21, r24 ; 0x15
volatile int led_Zehner = numbersAsSegments[(int) (count - (count % 10)) / 10]; // Segmentanzeige f<>r Einer volatile int led_Zehner = numbersAsSegments[(int) (count - (count % 10)) / 10]; // Segmentanzeige f<>r Einer
1ae: f9 01 movw r30, r18 256: e0 91 14 01 lds r30, 0x0114 ; 0x800114 <__data_end>
1b0: e8 1b sub r30, r24 25a: f0 91 15 01 lds r31, 0x0115 ; 0x800115 <__data_end+0x1>
1b2: f9 0b sbc r31, r25 25e: 80 91 14 01 lds r24, 0x0114 ; 0x800114 <__data_end>
1b4: cf 01 movw r24, r30 262: 90 91 15 01 lds r25, 0x0115 ; 0x800115 <__data_end+0x1>
1b6: b8 01 movw r22, r16 266: b9 01 movw r22, r18
1b8: 0e 94 0f 01 call 0x21e ; 0x21e <__divmodhi4> 268: 0e 94 6d 01 call 0x2da ; 0x2da <__divmodhi4>
1bc: fb 01 movw r30, r22 26c: af 01 movw r20, r30
1be: ee 0f add r30, r30 26e: 48 1b sub r20, r24
1c0: ff 1f adc r31, r31 270: 59 0b sbc r21, r25
1c2: 41 e0 ldi r20, 0x01 ; 1 272: ca 01 movw r24, r20
1c4: 50 e0 ldi r21, 0x00 ; 0 274: b9 01 movw r22, r18
1c6: 4c 0f add r20, r28 276: 0e 94 6d 01 call 0x2da ; 0x2da <__divmodhi4>
1c8: 5d 1f adc r21, r29 27a: fb 01 movw r30, r22
1ca: e4 0f add r30, r20 27c: ee 0f add r30, r30
1cc: f5 1f adc r31, r21 27e: ff 1f adc r31, r31
1ce: 80 81 ld r24, Z 280: 81 e0 ldi r24, 0x01 ; 1
1d0: 91 81 ldd r25, Z+1 ; 0x01 282: 90 e0 ldi r25, 0x00 ; 0
1d2: 98 8f std Y+24, r25 ; 0x18 284: 8c 0f add r24, r28
1d4: 8f 8b std Y+23, r24 ; 0x17 286: 9d 1f adc r25, r29
288: e8 0f add r30, r24
28a: f9 1f adc r31, r25
28c: 80 81 ld r24, Z
28e: 91 81 ldd r25, Z+1 ; 0x01
290: 98 8f std Y+24, r25 ; 0x18
292: 8f 8b std Y+23, r24 ; 0x17
PORTD = led_Einer; PORTD = led_Einer;
1d6: 8d 89 ldd r24, Y+21 ; 0x15 294: 8d 89 ldd r24, Y+21 ; 0x15
1d8: 9e 89 ldd r25, Y+22 ; 0x16 296: 9e 89 ldd r25, Y+22 ; 0x16
1da: 8b b9 out 0x0b, r24 ; 11 298: 8b b9 out 0x0b, r24 ; 11
#else //_delay_ms(10);
//round up by default waitFor(10);
__ticks_dc = (uint32_t)(ceil(fabs(__tmp))); 29a: 6a e0 ldi r22, 0x0A ; 10
#endif 29c: 70 e0 ldi r23, 0x00 ; 0
29e: 80 e0 ldi r24, 0x00 ; 0
__builtin_avr_delay_cycles(__ticks_dc); 2a0: 90 e0 ldi r25, 0x00 ; 0
1dc: 8f e3 ldi r24, 0x3F ; 63 2a2: 0e 94 a4 00 call 0x148 ; 0x148 <waitFor>
1de: 9c e9 ldi r25, 0x9C ; 156
1e0: 01 97 sbiw r24, 0x01 ; 1
1e2: f1 f7 brne .-4 ; 0x1e0 <display+0x84>
1e4: 00 c0 rjmp .+0 ; 0x1e6 <display+0x8a>
1e6: 00 00 nop
_delay_ms(10);
PORTB ^= (1 << PINB0); PORTB ^= (1 << PINB0);
1e8: 95 b1 in r25, 0x05 ; 5 2a6: 85 b1 in r24, 0x05 ; 5
1ea: 81 e0 ldi r24, 0x01 ; 1 2a8: 11 e0 ldi r17, 0x01 ; 1
1ec: 98 27 eor r25, r24 2aa: 81 27 eor r24, r17
1ee: 95 b9 out 0x05, r25 ; 5 2ac: 85 b9 out 0x05, r24 ; 5
PORTD = led_Zehner; PORTD = led_Zehner;
1f0: 2f 89 ldd r18, Y+23 ; 0x17 2ae: 8f 89 ldd r24, Y+23 ; 0x17
1f2: 38 8d ldd r19, Y+24 ; 0x18 2b0: 98 8d ldd r25, Y+24 ; 0x18
1f4: 2b b9 out 0x0b, r18 ; 11 2b2: 8b b9 out 0x0b, r24 ; 11
1f6: ef e3 ldi r30, 0x3F ; 63 //_delay_ms(10);
1f8: fc e9 ldi r31, 0x9C ; 156 waitFor(10);
1fa: 31 97 sbiw r30, 0x01 ; 1 2b4: 6a e0 ldi r22, 0x0A ; 10
1fc: f1 f7 brne .-4 ; 0x1fa <display+0x9e> 2b6: 70 e0 ldi r23, 0x00 ; 0
1fe: 00 c0 rjmp .+0 ; 0x200 <display+0xa4> 2b8: 80 e0 ldi r24, 0x00 ; 0
200: 00 00 nop 2ba: 90 e0 ldi r25, 0x00 ; 0
_delay_ms(10); 2bc: 0e 94 a4 00 call 0x148 ; 0x148 <waitFor>
PORTB ^= (1 << PINB0); PORTB ^= (1 << PINB0);
202: 95 b1 in r25, 0x05 ; 5 2c0: 85 b1 in r24, 0x05 ; 5
204: 89 27 eor r24, r25 2c2: 18 27 eor r17, r24
206: 85 b9 out 0x05, r24 ; 5 2c4: 15 b9 out 0x05, r17 ; 5
} }
208: 68 96 adiw r28, 0x18 ; 24 2c6: 68 96 adiw r28, 0x18 ; 24
20a: 0f b6 in r0, 0x3f ; 63 2c8: 0f b6 in r0, 0x3f ; 63
20c: f8 94 cli 2ca: f8 94 cli
20e: de bf out 0x3e, r29 ; 62 2cc: de bf out 0x3e, r29 ; 62
210: 0f be out 0x3f, r0 ; 63 2ce: 0f be out 0x3f, r0 ; 63
212: cd bf out 0x3d, r28 ; 61 2d0: cd bf out 0x3d, r28 ; 61
214: df 91 pop r29 2d2: df 91 pop r29
216: cf 91 pop r28 2d4: cf 91 pop r28
218: 1f 91 pop r17 2d6: 1f 91 pop r17
21a: 0f 91 pop r16 2d8: 08 95 ret
21c: 08 95 ret
0000021e <__divmodhi4>: 000002da <__divmodhi4>:
21e: 97 fb bst r25, 7 2da: 97 fb bst r25, 7
220: 07 2e mov r0, r23 2dc: 07 2e mov r0, r23
222: 16 f4 brtc .+4 ; 0x228 <__divmodhi4+0xa> 2de: 16 f4 brtc .+4 ; 0x2e4 <__divmodhi4+0xa>
224: 00 94 com r0 2e0: 00 94 com r0
226: 07 d0 rcall .+14 ; 0x236 <__divmodhi4_neg1> 2e2: 07 d0 rcall .+14 ; 0x2f2 <__divmodhi4_neg1>
228: 77 fd sbrc r23, 7 2e4: 77 fd sbrc r23, 7
22a: 09 d0 rcall .+18 ; 0x23e <__divmodhi4_neg2> 2e6: 09 d0 rcall .+18 ; 0x2fa <__divmodhi4_neg2>
22c: 0e 94 23 01 call 0x246 ; 0x246 <__udivmodhi4> 2e8: 0e 94 81 01 call 0x302 ; 0x302 <__udivmodhi4>
230: 07 fc sbrc r0, 7 2ec: 07 fc sbrc r0, 7
232: 05 d0 rcall .+10 ; 0x23e <__divmodhi4_neg2> 2ee: 05 d0 rcall .+10 ; 0x2fa <__divmodhi4_neg2>
234: 3e f4 brtc .+14 ; 0x244 <__divmodhi4_exit> 2f0: 3e f4 brtc .+14 ; 0x300 <__divmodhi4_exit>
00000236 <__divmodhi4_neg1>: 000002f2 <__divmodhi4_neg1>:
236: 90 95 com r25 2f2: 90 95 com r25
238: 81 95 neg r24 2f4: 81 95 neg r24
23a: 9f 4f sbci r25, 0xFF ; 255 2f6: 9f 4f sbci r25, 0xFF ; 255
23c: 08 95 ret 2f8: 08 95 ret
0000023e <__divmodhi4_neg2>: 000002fa <__divmodhi4_neg2>:
23e: 70 95 com r23 2fa: 70 95 com r23
240: 61 95 neg r22 2fc: 61 95 neg r22
242: 7f 4f sbci r23, 0xFF ; 255 2fe: 7f 4f sbci r23, 0xFF ; 255
00000244 <__divmodhi4_exit>: 00000300 <__divmodhi4_exit>:
244: 08 95 ret 300: 08 95 ret
00000246 <__udivmodhi4>: 00000302 <__udivmodhi4>:
246: aa 1b sub r26, r26 302: aa 1b sub r26, r26
248: bb 1b sub r27, r27 304: bb 1b sub r27, r27
24a: 51 e1 ldi r21, 0x11 ; 17 306: 51 e1 ldi r21, 0x11 ; 17
24c: 07 c0 rjmp .+14 ; 0x25c <__udivmodhi4_ep> 308: 07 c0 rjmp .+14 ; 0x318 <__udivmodhi4_ep>
0000024e <__udivmodhi4_loop>: 0000030a <__udivmodhi4_loop>:
24e: aa 1f adc r26, r26 30a: aa 1f adc r26, r26
250: bb 1f adc r27, r27 30c: bb 1f adc r27, r27
252: a6 17 cp r26, r22 30e: a6 17 cp r26, r22
254: b7 07 cpc r27, r23 310: b7 07 cpc r27, r23
256: 10 f0 brcs .+4 ; 0x25c <__udivmodhi4_ep> 312: 10 f0 brcs .+4 ; 0x318 <__udivmodhi4_ep>
258: a6 1b sub r26, r22 314: a6 1b sub r26, r22
25a: b7 0b sbc r27, r23 316: b7 0b sbc r27, r23
0000025c <__udivmodhi4_ep>: 00000318 <__udivmodhi4_ep>:
25c: 88 1f adc r24, r24 318: 88 1f adc r24, r24
25e: 99 1f adc r25, r25 31a: 99 1f adc r25, r25
260: 5a 95 dec r21 31c: 5a 95 dec r21
262: a9 f7 brne .-22 ; 0x24e <__udivmodhi4_loop> 31e: a9 f7 brne .-22 ; 0x30a <__udivmodhi4_loop>
264: 80 95 com r24 320: 80 95 com r24
266: 90 95 com r25 322: 90 95 com r25
268: bc 01 movw r22, r24 324: bc 01 movw r22, r24
26a: cd 01 movw r24, r26 326: cd 01 movw r24, r26
26c: 08 95 ret 328: 08 95 ret
0000026e <_exit>: 0000032a <_exit>:
26e: f8 94 cli 32a: f8 94 cli
00000270 <__stop_program>: 0000032c <__stop_program>:
270: ff cf rjmp .-2 ; 0x270 <__stop_program> 32c: ff cf rjmp .-2 ; 0x32c <__stop_program>

View File

@@ -7,7 +7,7 @@ c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/..
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_copy_data.o) c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_copy_data.o)
sevenseg.o (__do_copy_data) sevenseg.o (__do_copy_data)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o) c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_clear_bss.o)
main.o (__do_clear_bss) sevenseg.o (__do_clear_bss)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_udivmodhi4.o) c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_udivmodhi4.o)
c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o) (__udivmodhi4) c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o) (__udivmodhi4)
@@ -24,6 +24,8 @@ Discarded input sections
.text 0x00000000 0x0 sevenseg.o .text 0x00000000 0x0 sevenseg.o
.data 0x00000000 0x0 sevenseg.o .data 0x00000000 0x0 sevenseg.o
.bss 0x00000000 0x0 sevenseg.o .bss 0x00000000 0x0 sevenseg.o
.text.getSystemClock
0x00000000 0x12 sevenseg.o
.text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o) .text 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o)
.data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o) .data 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o)
.bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o) .bss 0x00000000 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o)
@@ -227,7 +229,7 @@ END GROUP
.rela.plt .rela.plt
*(.rela.plt) *(.rela.plt)
.text 0x00000000 0x272 .text 0x00000000 0x32e
*(.vectors) *(.vectors)
.vectors 0x00000000 0x68 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o .vectors 0x00000000 0x68 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
0x00000000 __vector_default 0x00000000 __vector_default
@@ -306,34 +308,44 @@ END GROUP
0x000000a2 __vector_21 0x000000a2 __vector_21
0x000000a2 __vector_15 0x000000a2 __vector_15
0x000000a2 __vector_8 0x000000a2 __vector_8
0x000000a2 __vector_14
0x000000a2 __vector_10 0x000000a2 __vector_10
0x000000a2 __vector_16 0x000000a2 __vector_16
0x000000a2 __vector_18 0x000000a2 __vector_18
0x000000a2 __vector_20 0x000000a2 __vector_20
0x000000a6 . = ALIGN (0x2) 0x000000a6 . = ALIGN (0x2)
*(.text.*) *(.text.*)
.text.init 0x000000a6 0x28 keys.o .text.setupTimer0
0x000000a6 init 0x000000a6 0x1c keys.o
0x000000a6 setupTimer0
.text.setupRegisters
0x000000c2 0x28 keys.o
0x000000c2 setupRegisters
.text.init 0x000000ea 0xa keys.o
0x000000ea init
.text.main 0x000000f4 0xa main.o
0x000000f4 main
.text.__vector_14
0x000000fe 0x4a sevenseg.o
0x000000fe __vector_14
.text.waitFor 0x00000148 0x40 sevenseg.o
0x00000148 waitFor
.text.__vector_3 .text.__vector_3
0x000000ce 0x7c main.o 0x00000188 0x7a sevenseg.o
0x000000ce __vector_3 0x00000188 __vector_3
.text.main 0x0000014a 0x12 main.o .text.display 0x00000202 0xd8 sevenseg.o
0x0000014a main 0x00000202 display
.text.display 0x0000015c 0xc2 sevenseg.o
0x0000015c display
.text.libgcc.div .text.libgcc.div
0x0000021e 0x28 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o) 0x000002da 0x28 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_divmodhi4.o)
0x0000021e _div 0x000002da _div
0x0000021e __divmodhi4 0x000002da __divmodhi4
.text.libgcc.div .text.libgcc.div
0x00000246 0x28 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_udivmodhi4.o) 0x00000302 0x28 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_udivmodhi4.o)
0x00000246 __udivmodhi4 0x00000302 __udivmodhi4
0x0000026e . = ALIGN (0x2) 0x0000032a . = ALIGN (0x2)
*(.fini9) *(.fini9)
.fini9 0x0000026e 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o) .fini9 0x0000032a 0x0 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o)
0x0000026e _exit 0x0000032a _exit
0x0000026e exit 0x0000032a exit
*(.fini9) *(.fini9)
*(.fini8) *(.fini8)
*(.fini8) *(.fini8)
@@ -352,11 +364,11 @@ END GROUP
*(.fini1) *(.fini1)
*(.fini1) *(.fini1)
*(.fini0) *(.fini0)
.fini0 0x0000026e 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o) .fini0 0x0000032a 0x4 c:/program files (x86)/atmel/studio/7.0/toolchain/avr8/avr8-gnu-toolchain/bin/../lib/gcc/avr/5.4.0/avr5\libgcc.a(_exit.o)
*(.fini0) *(.fini0)
0x00000272 _etext = . 0x0000032e _etext = .
.data 0x00800100 0x14 load address 0x00000272 .data 0x00800100 0x14 load address 0x0000032e
0x00800100 PROVIDE (__data_start, .) 0x00800100 PROVIDE (__data_start, .)
*(.data) *(.data)
*(.data*) *(.data*)
@@ -369,22 +381,25 @@ END GROUP
0x00800114 _edata = . 0x00800114 _edata = .
0x00800114 PROVIDE (__data_end, .) 0x00800114 PROVIDE (__data_end, .)
.bss 0x00800114 0x2 .bss 0x00800114 0x6
0x00800114 PROVIDE (__bss_start, .) 0x00800114 PROVIDE (__bss_start, .)
*(.bss) *(.bss)
*(.bss*) *(.bss*)
.bss.count 0x00800114 0x2 main.o .bss.count 0x00800114 0x2 sevenseg.o
0x00800114 count 0x00800114 count
.bss.systemClock
0x00800116 0x4 sevenseg.o
0x00800116 systemClock
*(COMMON) *(COMMON)
0x00800116 PROVIDE (__bss_end, .) 0x0080011a PROVIDE (__bss_end, .)
0x00000272 __data_load_start = LOADADDR (.data) 0x0000032e __data_load_start = LOADADDR (.data)
0x00000286 __data_load_end = (__data_load_start + SIZEOF (.data)) 0x00000342 __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00800116 0x0 .noinit 0x0080011a 0x0
[!provide] PROVIDE (__noinit_start, .) [!provide] PROVIDE (__noinit_start, .)
*(.noinit*) *(.noinit*)
[!provide] PROVIDE (__noinit_end, .) [!provide] PROVIDE (__noinit_end, .)
0x00800116 _end = . 0x0080011a _end = .
[!provide] PROVIDE (__heap_start, .) [!provide] PROVIDE (__heap_start, .)
.eeprom 0x00810000 0x0 .eeprom 0x00810000 0x0
@@ -451,59 +466,58 @@ END GROUP
.debug_sfnames .debug_sfnames
*(.debug_sfnames) *(.debug_sfnames)
.debug_aranges 0x00000000 0x68 .debug_aranges 0x00000000 0x90
*(.debug_aranges) *(.debug_aranges)
.debug_aranges .debug_aranges
0x00000000 0x20 keys.o 0x00000000 0x30 keys.o
.debug_aranges .debug_aranges
0x00000020 0x28 main.o 0x00000030 0x20 main.o
.debug_aranges .debug_aranges
0x00000048 0x20 sevenseg.o 0x00000050 0x40 sevenseg.o
.debug_pubnames .debug_pubnames
*(.debug_pubnames) *(.debug_pubnames)
.debug_info 0x00000000 0x8f2 .debug_info 0x00000000 0x94d
*(.debug_info .gnu.linkonce.wi.*) *(.debug_info .gnu.linkonce.wi.*)
.debug_info 0x00000000 0x5f4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o .debug_info 0x00000000 0x5f4 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_info 0x000005f4 0x82 keys.o .debug_info 0x000005f4 0xbf keys.o
.debug_info 0x00000676 0xe6 main.o .debug_info 0x000006b3 0xae main.o
.debug_info 0x0000075c 0x196 sevenseg.o .debug_info 0x00000761 0x1ec sevenseg.o
.debug_abbrev 0x00000000 0x797 .debug_abbrev 0x00000000 0x799
*(.debug_abbrev) *(.debug_abbrev)
.debug_abbrev 0x00000000 0x5a2 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o .debug_abbrev 0x00000000 0x5a2 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_abbrev 0x000005a2 0x4f keys.o .debug_abbrev 0x000005a2 0x70 keys.o
.debug_abbrev 0x000005f1 0xa5 main.o .debug_abbrev 0x00000612 0x68 main.o
.debug_abbrev 0x00000696 0x101 sevenseg.o .debug_abbrev 0x0000067a 0x11f sevenseg.o
.debug_line 0x00000000 0x448 .debug_line 0x00000000 0x432
*(.debug_line .debug_line.* .debug_line_end) *(.debug_line .debug_line.* .debug_line_end)
.debug_line 0x00000000 0x133 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o .debug_line 0x00000000 0x133 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_line 0x00000133 0xc3 keys.o .debug_line 0x00000133 0x107 keys.o
.debug_line 0x000001f6 0x107 main.o .debug_line 0x0000023a 0x5f main.o
.debug_line 0x000002fd 0x14b sevenseg.o .debug_line 0x00000299 0x199 sevenseg.o
.debug_frame 0x00000000 0xac .debug_frame 0x00000000 0x124
*(.debug_frame) *(.debug_frame)
.debug_frame 0x00000000 0x24 keys.o .debug_frame 0x00000000 0x44 keys.o
.debug_frame 0x00000024 0x48 main.o .debug_frame 0x00000044 0x24 main.o
.debug_frame 0x0000006c 0x40 sevenseg.o .debug_frame 0x00000068 0xbc sevenseg.o
.debug_str 0x00000000 0x41d .debug_str 0x00000000 0x42d
*(.debug_str) *(.debug_str)
.debug_str 0x00000000 0x208 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o .debug_str 0x00000000 0x208 C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/gcc/dev/atmega328p/avr5/crtatmega328p.o
.debug_str 0x00000208 0x160 keys.o .debug_str 0x00000208 0x17b keys.o
0x194 (size before relaxing) 0x1af (size before relaxing)
.debug_str 0x00000368 0x2a main.o .debug_str 0x00000383 0x19 main.o
0x1b2 (size before relaxing) 0x199 (size before relaxing)
.debug_str 0x00000392 0x8b sevenseg.o .debug_str 0x0000039c 0x91 sevenseg.o
0x21c (size before relaxing) 0x21c (size before relaxing)
.debug_loc 0x00000000 0x170 .debug_loc 0x00000000 0x12f
*(.debug_loc) *(.debug_loc)
.debug_loc 0x00000000 0x49 main.o .debug_loc 0x00000000 0x12f sevenseg.o
.debug_loc 0x00000049 0x127 sevenseg.o
.debug_macinfo .debug_macinfo
*(.debug_macinfo) *(.debug_macinfo)
@@ -523,11 +537,11 @@ END GROUP
.debug_pubtypes .debug_pubtypes
*(.debug_pubtypes) *(.debug_pubtypes)
.debug_ranges 0x00000000 0x38 .debug_ranges 0x00000000 0x60
*(.debug_ranges) *(.debug_ranges)
.debug_ranges 0x00000000 0x10 keys.o .debug_ranges 0x00000000 0x20 keys.o
.debug_ranges 0x00000010 0x18 main.o .debug_ranges 0x00000020 0x10 main.o
.debug_ranges 0x00000028 0x10 sevenseg.o .debug_ranges 0x00000030 0x30 sevenseg.o
.debug_macro .debug_macro
*(.debug_macro) *(.debug_macro)

View File

@@ -1,44 +1,55 @@
S00A000050342E7372656396 S00A000050342E7372656396
S11300000C9434000C9451000C9451000C9467002F S11300000C9434000C9451000C9451000C94C400D2
S11300100C9451000C9451000C9451000C94510018 S11300100C9451000C9451000C9451000C94510018
S11300200C9451000C9451000C9451000C94510008 S11300200C9451000C9451000C9451000C94510008
S11300300C9451000C9451000C9451000C945100F8 S11300300C9451000C9451000C947F000C945100CA
S11300400C9451000C9451000C9451000C945100E8 S11300400C9451000C9451000C9451000C945100E8
S11300500C9451000C9451000C9451000C945100D8 S11300500C9451000C9451000C9451000C945100D8
S11300600C9451000C94510011241FBECFEFD8E022 S11300600C9451000C94510011241FBECFEFD8E022
S1130070DEBFCDBF11E0A0E0B1E0E2E7F2E002C0F4 S1130070DEBFCDBF11E0A0E0B1E0EEE2F3E002C0EC
S113008005900D92A431B107D9F721E0A4E1B1E0C4 S113008005900D92A431B107D9F721E0A4E1B1E0C4
S113009001C01D92A631B207E1F70E94A5000C949D S113009001C01D92AA31B207E1F70E947A000C94C4
S11300A037010C9400008FEF8AB981E084B985B1DF S11300A095010C94000084B5826084BD85B583609D
S11300B0866085B9F894E8E6F0E080818160808309 S11300B085BD89EF87BDEEE6F0E0808182608083B4
S11300C0EBE6F0E0808186608083789408951F9247 S11300C008958FEF8AB981E084B985B1866085B9D6
S11300D00F920FB60F9211248F939F93199916C004 S11300D0F894E8E6F0E0808181608083EBE6F0E06C
S11300E08091140190911501892B31F484E690E0FC S11300E0808186608083789408950E9453000E94E2
S11300F0909315018093140180911401909115013E S11300F0610008950E9475000E940101FDCF1F92C6
S11301000197909315018093140118C01A9916C091 S11301000F920FB60F9211248F939F93AF93BF93C7
S113011080911401909115018336910531F48FEF8C S11301108091160190911701A0911801B0911901D5
S11301209FEF909315018093140180911401909195 S11301200196A11DB11D8093160190931701A09310
S11301301501019690931501809314019F918F915D S11301301801B0931901BF91AF919F918F910F90C6
S11301400F900FBE0F901F9018950E94530080913E S11301400FBE0F901F9018950F931F9300911601E7
S11301501401909115010E94AE00F9CF0F931F93E3 S1130150109117012091180130911901AB01BC01D4
S1130160CF93DF93CDB7DEB768970FB6F894DEBFB1 S1130160400F511F621F731F809116019091170158
S11301700FBECDBF9C0184E1E0E0F1E0DE01119609 S1130170A0911801B091190184179507A607B70734
S113018001900D928A95E1F70AE010E0C901B801E7 S113018099F71F910F9108951F920F920FB60F9236
S11301900E940F01FC01EE0FFF1F41E050E04C0FE5 S113019011248F939F93199915C080911401909104
S11301A05D1FE40FF51F408151815E8B4D8BF9017A S11301A01501892B31F484E690E090931501809336
S11301B0E81BF90BCF01B8010E940F01FB01EE0F00 S11301B014018091140190911501019790931501F8
S11301C0FF1F41E050E04C0F5D1FE40FF51F8081DD S11301C0809314011A9916C080911401909115011D
S11301D09181988F8F8B8D899E898BB98FE39CE950 S11301D08336910531F48FEF9FEF9093150180934F
S11301E00197F1F700C0000095B181E0982795B917 S11301E014018091140190911501019690931501C9
S11301F02F89388D2BB9EFE3FCE93197F1F700C073 S11301F0809314019F918F910F900FBE0F901F90C9
S1130200000095B1892785B968960FB6F894DEBFCA S113020018951F93CF93DF93CDB7DEB768970FB6DA
S11302100FBECDBFDF91CF911F910F91089597FB32 S1130210F894DEBF0FBECDBF84E1E0E0F1E0DE0183
S1130220072E16F4009407D077FD09D00E9423010D S1130220119601900D928A95E1F7809114019091B5
S113023007FC05D03EF4909581959F4F08957095E5 S113023015012AE030E0B9010E946D01FC01EE0FC6
S113024061957F4F0895AA1BBB1B51E107C0AA1FEC S1130240FF1F41E050E04C0F5D1FE40FF51F80815C
S1130250BB1FA617B70710F0A61BB70B881F991F63 S113025091819E8B8D8BE0911401F0911501809119
S11302605A95A9F780959095BC01CD010895F8940D S1130260140190911501B9010E946D01AF01481B61
S1050270FFCFBA S1130270590BCA01B9010E946D01FB01EE0FFF1F6A
S1130272C000F900A4003000990092008200F80046 S113028081E090E08C0F9D1FE80FF91F8081918120
S10702828000900064 S1130290988F8F8B8D899E898BB96AE070E080E09E
S11302A090E00E94A40085B111E0812785B98F896F
S11302B0988D8BB96AE070E080E090E00E94A40021
S11302C085B1182715B968960FB6F894DEBF0FBE2E
S11302D0CDBFDF91CF911F91089597FB072E16F4A0
S11302E0009407D077FD09D00E94810107FC05D056
S11302F03EF4909581959F4F0895709561957F4F39
S11303000895AA1BBB1B51E107C0AA1FBB1FA61758
S1130310B70710F0A61BB70B881F991F5A95A9F7AA
S111032080959095BC01CD010895F894FFCF0F
S113032EC000F900A4003000990092008200F80089
S107033E80009000A7
S9030000FC S9030000FC

Binary file not shown.

Binary file not shown.

View File

@@ -5,6 +5,7 @@ sevenseg.d sevenseg.o: .././sevenseg.c .././sevenseg.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\stdint.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay_basic.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h \
C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom328p.h \ C:\Program\ Files\ (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom328p.h \
@@ -28,6 +29,8 @@ c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h: c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\math.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\interrupt.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h: c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\io.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h: c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\sfr_defs.h:

Binary file not shown.

View File

@@ -1,22 +1,34 @@
#include "keys.h" #include "keys.h"
void setupTimer0() {
void init(){ // Configure Timer0 for CTC mode
DDRD = 0xff; // Data direction register D (D0 -> D6) as output TCCR0A |= (1 << WGM01); // Set Waveform Generation Mode bits for CTC
// PORTD = 0xff; // setting bit for 7-segment show 0 TCCR0B |= (1 << CS01) | (1 << CS00); // Set prescaler to 64
// => spielt keine Rolle, wird von der while Schleife <20>bernommen OCR0A = 249; // Set Output Compare Register to 249 for ~1ms interrupt
TIMSK0 |= (1 << OCIE0A); // Enable Timer0 Output Compare A Match interrupt
DDRB = 0x01; // Data direction register B (B0) as output and DDRB (B1, B2) as input
PORTB |= (1 << PINB1) | (1 << PINB2) ; // setting bit for teens and SW1-2
// PINB=0 => start with LED3 (Einer)
// mit unserem Atmega nicht m<>glich, da keine PCINT8_vect und PCINT9_vect vorhanden
// DDRC = 0x00; // Data direction register C as input for SW1 and SW2
// PORTC |= (1<<PINC0) | (1<<PINC1); // settings pins for SW1 -> PINC0 and SW2 -> PINC1
cli(); // clear global interrupt flag: interrupts will be immediately disabled
PCICR |= 0x01; // Pin Change Interrupt Control Register: turn on PortB
PCMSK0 |= (1 << PINB1) | (1 << PINB2); // trigger interrupt when SW1 or SW2 is pressed
sei(); // set global interrupt enable
} }
void setupRegisters(){
DDRD = 0xff; // Data direction register D (D0 -> D6) as output
// PORTD = 0xff; // setting bit for 7-segment show 0
// => spielt keine Rolle, wird von der while Schleife <20>bernommen
DDRB = 0x01; // Data direction register B (B0) as output and DDRB (B1, B2) as input
PORTB |= (1 << PINB1) | (1 << PINB2) ; // setting bit for teens B0=0 and SW1-2
// PINB=0 => start with LED3 (Einer)
// mit unserem Atmega nicht m<>glich, da keine PCINT8_vect und PCINT9_vect vorhanden
// DDRC = 0x00; // Data direction register C as input for SW1 and SW2
// PORTC |= (1<<PINC0) | (1<<PINC1); // settings pins for SW1 -> PINC0 and SW2 -> PINC1
cli(); // clear global interrupt flag: interrupts will be immediately disabled
PCICR |= 0x01; // Pin Change Interrupt Control Register: turn on PortB
PCMSK0 |= (1 << PINB1) | (1 << PINB2); // trigger interrupt when SW1 or SW2 is pressed
sei(); // set global interrupt enable
}
void init(){
setupTimer0();
setupRegisters();
}

View File

@@ -4,6 +4,8 @@
#include <avr/io.h> #include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
void setupTimer0();
void setupRegisters();
void init(); void init();

View File

@@ -1,26 +1,11 @@
#include "keys.h" #include "keys.h"
#include "sevenseg.h" #include "sevenseg.h"
volatile int count = 0;
ISR(PCINT0_vect) { // every 10ms interrupt is triggered
if (!(PINB & (1<<PINB1))) { // count down => sw1 is pressed
if (count == 0) count = 100; // 100 - 1 = 99
count--;
}
if (!(PINB & (1<<PINB2))) { // count up => sw2 is pressed
if (count == 99) count = -1; // -1 + 1 = 0
count++;
}
}
int main(void) { int main(void) {
init(); init();
while(1) { while(1) {
display(count); display();
} }
} }

View File

@@ -1,6 +1,42 @@
#include "sevenseg.h" #include "sevenseg.h"
void display(int count) { //-Timer---------------------------------------
volatile uint32_t systemClock = 0;
ISR(TIMER0_COMPA_vect) {
systemClock++;
}
uint32_t getSystemClock(){
return systemClock;
}
void waitFor(uint32_t ms) {
uint32_t endTime = getSystemClock() + ms;
while (getSystemClock() != endTime);
}
//-Counter-------------------------------------
volatile int count = 0;
ISR(PCINT0_vect) { // every 10ms interrupt is triggered
if (!(PINB & (1<<PINB1))) { // count down => sw1 is pressed
if (count == 0) count = 100; // 100 - 1 = 99
count--;
}
if (!(PINB & (1<<PINB2))) { // count up => sw2 is pressed
if (count == 99) count = -1; // -1 + 1 = 0
count++;
}
}
//-Display--------------------------------------
void display() {
/* /*
logical 0: on logical 0: on
logical 1: off logical 1: off
@@ -20,14 +56,16 @@ void display(int count) {
int numbersAsSegments[10] = { 192, 249, 164, 48, 153, 146, 130, 248, 128, 144 }; // display number from 0 to 9; int numbersAsSegments[10] = { 192, 249, 164, 48, 153, 146, 130, 248, 128, 144 }; // display number from 0 to 9;
volatile int led_Einer = numbersAsSegments[(int) count % 10]; // Segmentanzeige f<>r Zehner volatile int led_Einer = numbersAsSegments[(int) count % 10]; // Segmentanzeige f<>r Zehner
volatile int led_Zehner = numbersAsSegments[(int) (count - (count % 10)) / 10]; // Segmentanzeige f<>r Einer volatile int led_Zehner = numbersAsSegments[(int) (count - (count % 10)) / 10]; // Segmentanzeige f<>r Einer
PORTD = led_Einer; PORTD = led_Einer;
_delay_ms(10); //_delay_ms(10);
waitFor(10);
PORTB ^= (1 << PINB0); PORTB ^= (1 << PINB0);
PORTD = led_Zehner; PORTD = led_Zehner;
_delay_ms(10); //_delay_ms(10);
waitFor(10);
PORTB ^= (1 << PINB0); PORTB ^= (1 << PINB0);
} }

View File

@@ -2,8 +2,11 @@
#define SEVENSEG_H_ #define SEVENSEG_H_
#define F_CPU 16000000UL // 16MHz clock frequency #define F_CPU 16000000UL // 16MHz clock frequency
#include <util/delay.h> #include <util/delay.h>
#include <avr/interrupt.h>
#include "avr/io.h" #include "avr/io.h"
void display(int count); uint32_t getSystemClock();
void waitFor(uint32_t ms);
void display();
#endif /* SEVENSEG_H_ */ #endif /* SEVENSEG_H_ */

18
P5/.vscode/c_cpp_properties.json vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "windows-msvc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "cl.exe",
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "windows-msvc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

15
P5/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppvsdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"console": "externalTerminal",
"cwd": "c:/Users/Safak/SynologyDrive/UNI/3. Semester/53107 ARBK/Praktikumsunterlagen/ARBKVS-Praktika/P5",
"program": "c:/Users/Safak/SynologyDrive/UNI/3. Semester/53107 ARBK/Praktikumsunterlagen/ARBKVS-Praktika/P5/build/Debug/outDebug"
}
]
}

115
P5/.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,115 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "c++14",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": true,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"files.associations": {
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xutility": "cpp"
}
}

142
P5/Main.cpp Normal file
View File

@@ -0,0 +1,142 @@
#include <iostream>
#include <thread>
#include <mutex>
#include "Semaphore.h"
#include <process.h>
using namespace std;
// Thread T1 - Schreibt alle Kleinbuchstaben des Alphabets
void thread1() {
for (char c = 'a'; c <= 'z'; ++c) {
cout << c << ' ';
}
cout << endl;
}
// Thread T2 - Schreibt alle natürlichen Zahlen von 0 bis 32
void thread2() {
for (int i = 0; i <= 32; ++i) {
cout << i << ' ';
}
cout << endl;
}
// Thread T3 - Schreibt alle Großbuchstaben des Alphabets
void thread3() {
for (char c = 'A'; c <= 'Z'; ++c) {
cout << c << ' ';
}
cout << endl;
}
void asynch_init(){
// Start der Threads
thread t1(thread1);
thread t2(thread2);
thread t3(thread3);
// Warten auf die Beendigung der Threads
t1.join();
t2.join();
t3.join();
}
mutex mtx;
void mutexThread1() {
mtx.lock();
for (char ch = 'a'; ch <= 'z'; ch++) {
cout << ch << " ";
}
cout << endl;
mtx.unlock();
}
void mutexThread2() {
mtx.lock();
for (int i = 0; i < 33; i++) {
cout << i << " ";
}
cout << endl;
mtx.unlock();
}
void mutexThread3() {
mtx.lock();
for (char ch = 'A'; ch <= 'Z'; ch++) {
cout << ch << " ";
}
cout << endl;
mtx.unlock();
}
void mutex_init() {
thread t1(mutexThread1); // mutexThread1 is running
thread t2(mutexThread2); // mutexThread2 is running
thread t3(mutexThread3); // mutexThread3 is running
t1.join(); // main thread waits for t1 to finish
t2.join(); // main thread waits for t2 to finish
t3.join(); // main thread waits for t3 to finish
}
Semaphore semaphore;
void semaphoreThread1() {
semaphore.wait();
for (char ch = 'a'; ch <= 'z'; ch++) {
cout << ch << " ";
}
cout << endl;
semaphore.post();
}
void semaphoreThread2() {
semaphore.wait();
for (int i = 0; i < 33; i++) {
cout << i << " ";
}
cout << endl;
semaphore.post();
}
void semaphoreThread3() {
semaphore.wait();
for (char ch = 'A'; ch <= 'Z'; ch++) {
cout << ch << " ";
}
cout << endl;
semaphore.post();
}
void semaphore_init() {
thread t1(semaphoreThread1); // thread1 is running
thread t2(semaphoreThread2); // thread2 is running
thread t3(semaphoreThread3); // thread3 is running
t1.join(); // main thread waits for t1 to finish
t2.join(); // main thread waits for t2 to finish
t3.join(); // main thread waits for t3 to finish
}
int main() {
cout << "Asynch" << endl;
asynch_init();
cout << "Mutex" << endl;
mutex_init();
cout << "Semaphore" << endl;
semaphore_init();
return 0;
}

52
P5/Semaphore.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef MULTITHREADING_SEMAPHORE_H
#define MULTITHREADING_SEMAPHORE_H
#include <mutex>
#include <condition_variable>
class Semaphore {
private:
std::mutex mtx;
std::condition_variable cv;
int signal;
public:
Semaphore(int signal_ = 1) : signal(signal_) { }
/**
* atomic function
*/
inline void post() {
std::unique_lock<std::mutex> lock(mtx);
signal++;
//notify the waiting thread
//unblock(), waiting queue it not empty, wake up call thread from waiting queue
cv.notify_one();
/** Notify one
* Unblocks one of the threads currently waiting for this condition.
* If no threads are waiting, the function does nothing.
*/
}
/**
* atomic function
*/
inline void wait() {
std::unique_lock<std::mutex> lock(mtx);
if (signal <= 0) {
// wait on the mutex until notify is called
// block(), put this thread into waiting status, sleep and put in waiting queue
cv.wait(lock);
}
if (signal > 0) {
signal--;
}
}
};
#endif //MULTITHREADING_SEMAPHORE_H