150 lines
4.7 KiB
Plaintext
150 lines
4.7 KiB
Plaintext
|
|
main.elf: file format elf32-avr
|
|
|
|
Sections:
|
|
Idx Name Size VMA LMA File off Algn
|
|
0 .text 00000062 00000000 00000000 00000074 2**1
|
|
CONTENTS, ALLOC, LOAD, READONLY, CODE
|
|
1 .data 00000000 00800060 00000062 000000d6 2**0
|
|
CONTENTS, ALLOC, LOAD, DATA
|
|
2 .comment 00000011 00000000 00000000 000000d6 2**0
|
|
CONTENTS, READONLY
|
|
3 .note.gnu.avr.deviceinfo 0000003c 00000000 00000000 000000e8 2**2
|
|
CONTENTS, READONLY
|
|
4 .debug_aranges 00000028 00000000 00000000 00000124 2**0
|
|
CONTENTS, READONLY, DEBUGGING
|
|
5 .debug_info 00000410 00000000 00000000 0000014c 2**0
|
|
CONTENTS, READONLY, DEBUGGING
|
|
6 .debug_abbrev 0000037f 00000000 00000000 0000055c 2**0
|
|
CONTENTS, READONLY, DEBUGGING
|
|
7 .debug_line 0000010a 00000000 00000000 000008db 2**0
|
|
CONTENTS, READONLY, DEBUGGING
|
|
8 .debug_frame 00000064 00000000 00000000 000009e8 2**2
|
|
CONTENTS, READONLY, DEBUGGING
|
|
9 .debug_str 00000217 00000000 00000000 00000a4c 2**0
|
|
CONTENTS, READONLY, DEBUGGING
|
|
10 .debug_ranges 00000018 00000000 00000000 00000c63 2**0
|
|
CONTENTS, READONLY, DEBUGGING
|
|
|
|
Disassembly of section .text:
|
|
|
|
00000000 <__vectors>:
|
|
0: 09 c0 rjmp .+18 ; 0x14 <__ctors_end>
|
|
2: 0e c0 rjmp .+28 ; 0x20 <__bad_interrupt>
|
|
4: 0d c0 rjmp .+26 ; 0x20 <__bad_interrupt>
|
|
6: 0c c0 rjmp .+24 ; 0x20 <__bad_interrupt>
|
|
8: 0b c0 rjmp .+22 ; 0x20 <__bad_interrupt>
|
|
a: 0a c0 rjmp .+20 ; 0x20 <__bad_interrupt>
|
|
c: 09 c0 rjmp .+18 ; 0x20 <__bad_interrupt>
|
|
e: 08 c0 rjmp .+16 ; 0x20 <__bad_interrupt>
|
|
10: 07 c0 rjmp .+14 ; 0x20 <__bad_interrupt>
|
|
12: 06 c0 rjmp .+12 ; 0x20 <__bad_interrupt>
|
|
|
|
00000014 <__ctors_end>:
|
|
14: 11 24 eor r1, r1
|
|
16: 1f be out 0x3f, r1 ; 63
|
|
18: cf e9 ldi r28, 0x9F ; 159
|
|
1a: cd bf out 0x3d, r28 ; 61
|
|
1c: 1a d0 rcall .+52 ; 0x52 <main>
|
|
1e: 1f c0 rjmp .+62 ; 0x5e <_exit>
|
|
|
|
00000020 <__bad_interrupt>:
|
|
20: ef cf rjmp .-34 ; 0x0 <__vectors>
|
|
|
|
00000022 <adc_setup>:
|
|
#include "main.h"
|
|
|
|
void adc_setup (void)
|
|
{
|
|
// Set the ADC input to PB2/ADC1
|
|
ADMUX |= (1 << MUX0);
|
|
22: 38 9a sbi 0x07, 0 ; 7
|
|
ADMUX |= (1 << ADLAR);
|
|
24: 3d 9a sbi 0x07, 5 ; 7
|
|
// Set the prescaler to clock/128 & enable ADC
|
|
ADCSRA |= (1 << ADPS1) | (1 << ADPS0) | (1 << ADEN);
|
|
26: 86 b1 in r24, 0x06 ; 6
|
|
28: 83 68 ori r24, 0x83 ; 131
|
|
2a: 86 b9 out 0x06, r24 ; 6
|
|
2c: 08 95 ret
|
|
|
|
0000002e <adc_read>:
|
|
}
|
|
|
|
int adc_read (void)
|
|
{
|
|
// Start the conversion
|
|
ADCSRA |= (1 << ADSC);
|
|
2e: 36 9a sbi 0x06, 6 ; 6
|
|
// Wait for it to finish
|
|
while (ADCSRA & (1 << ADSC));
|
|
30: 36 99 sbic 0x06, 6 ; 6
|
|
32: fe cf rjmp .-4 ; 0x30 <adc_read+0x2>
|
|
return ADCH;
|
|
34: 85 b1 in r24, 0x05 ; 5
|
|
}
|
|
36: 90 e0 ldi r25, 0x00 ; 0
|
|
38: 08 95 ret
|
|
|
|
0000003a <pwm_setup>:
|
|
|
|
void pwm_setup (void)
|
|
{
|
|
// Set Timer 0 prescaler to clock/8.
|
|
// At 9.6 MHz this is 1.2 MHz.
|
|
TCCR0B |= (1 << CS01) | (1 << CS00);
|
|
3a: 83 b7 in r24, 0x33 ; 51
|
|
3c: 83 60 ori r24, 0x03 ; 3
|
|
3e: 83 bf out 0x33, r24 ; 51
|
|
// Set to 'Fast PWM' mode
|
|
TCCR0A |= (1 << WGM01) | (1 << WGM00);
|
|
40: 8f b5 in r24, 0x2f ; 47
|
|
42: 83 60 ori r24, 0x03 ; 3
|
|
44: 8f bd out 0x2f, r24 ; 47
|
|
// Clear OC0B output on compare match, upwards counting.
|
|
TCCR0A |= (1 << COM0B1);
|
|
46: 8f b5 in r24, 0x2f ; 47
|
|
48: 80 62 ori r24, 0x20 ; 32
|
|
4a: 8f bd out 0x2f, r24 ; 47
|
|
4c: 08 95 ret
|
|
|
|
0000004e <pwm_write>:
|
|
}
|
|
|
|
void pwm_write (int val)
|
|
{
|
|
OCR0B = val;
|
|
4e: 89 bd out 0x29, r24 ; 41
|
|
50: 08 95 ret
|
|
|
|
00000052 <main>:
|
|
|
|
int main (void)
|
|
{
|
|
int adc_in;
|
|
// LED is an output.
|
|
DDRB |= (1 << LED);
|
|
52: bb 9a sbi 0x17, 3 ; 23
|
|
adc_setup();
|
|
54: e6 df rcall .-52 ; 0x22 <adc_setup>
|
|
pwm_setup();
|
|
56: f1 df rcall .-30 ; 0x3a <pwm_setup>
|
|
while (1) {
|
|
// Get the ADC value
|
|
adc_in = adc_read();
|
|
58: ea df rcall .-44 ; 0x2e <adc_read>
|
|
TCCR0A |= (1 << COM0B1);
|
|
}
|
|
|
|
void pwm_write (int val)
|
|
{
|
|
OCR0B = val;
|
|
5a: 89 bd out 0x29, r24 ; 41
|
|
5c: fd cf rjmp .-6 ; 0x58 <main+0x6>
|
|
|
|
0000005e <_exit>:
|
|
5e: f8 94 cli
|
|
|
|
00000060 <__stop_program>:
|
|
60: ff cf rjmp .-2 ; 0x60 <__stop_program>
|