Commit ac61bd30 authored by BuildTools's avatar BuildTools

Fixed PWM

parent 9788a10e
/*
* PWM-LF.c
*
* Created: 29.01.2017 23:43:39
* Author : Petter
*/
#define F_CPU 3333333UL
#define F_CPU 20000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#define LED1 0 // port B, connected to WO0
#define LED2 1 // port B, connected to WO1
#define LED3 4 // Port B
#define SW1 5 // Port A
#define SW2 6 // Port A
#define SW3 7 // Port A
/*
In the pin definitions below, we have defined the PORT as well.
Everything works the same way as before, except you have to change PORTx with the PORT definition.
Example: LED1_PORT.OUTSET = (1 << LED1);
*/
#define LED1 4 //pin
#define LED2 5 //pin
#define LED3 5 //pin
#define LED1_PORT PORTD //port
#define LED2_PORT PORTD //port
#define LED3_PORT PORTC //port
#define SW1 2 //pin
#define SW2 1 //pin
#define SW3 2 //pin
bool SW1_pressed,SW2_pressed; //Keeping track of button status
#define SW1_PORT PORTC //port
#define SW2_PORT PORTD //port
#define SW3_PORT PORTD //port
#define TOP_PERIOD 0x55
/*
In this exercise, you will use PWM to control the brightness of LEDs
Once we have PWM set up, controlling the brightness is super easy!
*/
int main(void)
{
//Set LED pins as output
PORTB.DIRSET = (1 << LED1) | (1 << LED2) | (1 << LED3);
//Because the LEDs are active low, we invert the output. This means high PWM value -> bright led
PORTB.PIN0CTRL |= (1 << PORT_INVEN_bp);
PORTB.PIN1CTRL |= (1 << PORT_INVEN_bp);
PORTB.PIN4CTRL |= (1 << PORT_INVEN_bp);
sei();
//Pullups
PORTA.PIN5CTRL |= (1 << PORT_PULLUPEN_bp);
PORTA.PIN6CTRL |= (1 << PORT_PULLUPEN_bp);
PORTA.PIN7CTRL |= (1 << PORT_PULLUPEN_bp);
LED1_PORT.DIRSET = (1 << LED1); //Datasheet say that we should put pins to PWM as outputs.
LED2_PORT.DIRSET = (1 << LED2); //Also, since we put signals out on them, this make sense.
/*We will be using timer 1 in single (not split) mode.
It is highly recommended that you read chapter 20.3.3.4 in the datasheet
on timer compare channels.
There you will find a sub-capter on the single-slope PWM we will be using.
/**
In dataheet: "http://ww1.microchip.com/downloads/en/DeviceDoc/40002016A.pdf", section 4.1, Multiplexed signals, we see that if we want to use TCA0 with PD4 and PD5,
we need to use portmux to change TCA to Port D. We find that the led is at port D, pin 4 and 5 by looking at datasheets and silk text for PCBs.
*/
PORTMUX.TCAROUTEA = (0x3 << 0);
//First, enable the timer
TCA0.SINGLE.CTRLA |= (TCA_SINGLE_ENABLE_bm);
TCA0.SPLIT.CTRLD |= (1 << TCA_SPLIT_SPLITM_bp); //Set splitmode to get access to WO4 and WO5
//Set the mode of the timer to single slope PWM
TCA0.SINGLE.CTRLB |= (0x03 << TCA_SINGLE_WGMODE0_bp);
//We have to override the normal pin opperation so the PWM is pushed directly to the pin
//Hint: WO0 and WO1 are connected to leds. We need to override them to get the PWM out.
TCA0.SINGLE.CTRLB |= (TCA_SINGLE_CMP0EN_bm) | (TCA_SINGLE_CMP1EN_bm);
/*Timer A is a 16 bit timer. This will give us a frequency of 25Hz, we can see it flicker.
By lowering the period, (PER) we get higher frequency at the cost of lower resolution.
*/
TCA0.SPLIT.CTRLA |= (1 << TCA_SPLIT_ENABLE_bp) | (TCA_SPLIT_CLKSEL_DIV1_gc); //Enable the TCA and set prescaler to 1. Try different prescalers and see what happens.
//Set the period to 12 bit. (This results in a frequency of ~400Hz.)
TCA0.SINGLE.PER = 0x0fff; //We set our top to have a sufficiently high frequency (Top at 16 bit (0xffff) ~25Hz, 12 bit (0x0fff) ~400Hz)
TCA0.SPLIT.CTRLB |= (1 << TCA_SPLIT_HCMP1EN_bp) | (1 << TCA_SPLIT_HCMP2EN_bp); //Enable High Compare 1 and 2 to get output on WO4 and WO5. See Figure 19-13 in functional description datasheet.
//We can now control the PWM duty cycle by simply writing values to the CMP0 and CMP1 registers.
TCA0.SINGLE.CMP0 = 0x0000; //We have inverted the pin outputs so this is MIN
TCA0.SINGLE.CMP1 = 0x0fff; //We have inverted the pin outputs so this is MAX
TCA0.SPLIT.HPER = TOP_PERIOD; // Set period for High compare. See figures in datasheet. But this is the PWM Period.
TCA0.SPLIT.HCMP1 = 0x00; //See figures in datasheet. This is the PWM duty cycle.
TCA0.SPLIT.HCMP2 = 0x00;
while(1){
......@@ -74,37 +73,19 @@ int main(void)
Change the brightness based on buttons
*/
//Here we use button pushes to shift the CMP register so we get brightness steps
//adding and subtracting works just as well
//It is largely up to the student to choose how the led brightness is changed.
if (!(PORTA.IN & (1 << SW1))){
if(!SW1_pressed){
TCA0.SINGLE.CMP0 = (((TCA0.SINGLE.CMP0 << 1) + 1) & (0x0fff)); //Shift in a 1, and cut off excess to 12 bit
TCA0.SINGLE.CMP1 >>= 1;
SW1_pressed = true;
}
}
else{
SW1_pressed = false;
}
if (!(PORTA_IN & (1 << SW2))){
if(!SW2_pressed){
TCA0.SINGLE.CMP1 = (((TCA0.SINGLE.CMP1 << 1) + 1) & (0x0fff)); //Shift in a 1, and cut off excess to 12 bit
TCA0.SINGLE.CMP0 >>= 1;
SW2_pressed = true;
}
for (uint8_t i = 0; i < TOP_PERIOD; i++) {
TCA0.SPLIT.HCMP1 = i;
TCA0.SPLIT.HCMP2 = TOP_PERIOD-i;
_delay_ms(2);
}
else{
SW2_pressed = false;
for (uint8_t i = TOP_PERIOD; i > 0;i--) {
TCA0.SPLIT.HCMP1 = i;
TCA0.SPLIT.HCMP2 = TOP_PERIOD-i;
_delay_ms(2);
}
}
}
}

Microsoft Visual Studio Solution File, Format Version 12.00
# Atmel Studio Solution File, Format Version 11.00
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "PWM", "PWM\PWM.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AVR = Debug|AVR
Release|AVR = Release|AVR
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.ActiveCfg = Debug|AVR
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
SHELL := cmd.exe
RM := rm -rf
USER_OBJS :=
LIBS :=
PROJ :=
O_SRCS :=
C_SRCS :=
S_SRCS :=
S_UPPER_SRCS :=
OBJ_SRCS :=
ASM_SRCS :=
PREPROCESSING_SRCS :=
OBJS :=
OBJS_AS_ARGS :=
C_DEPS :=
C_DEPS_AS_ARGS :=
EXECUTABLES :=
OUTPUT_FILE_PATH :=
OUTPUT_FILE_PATH_AS_ARGS :=
AVR_APP_PATH :=$$$AVR_APP_PATH$$$
QUOTE := "
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:=
LIB_DEP:=
LINKER_SCRIPT_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS :=
# Add inputs and outputs from these tool invocations to the build variables
C_SRCS += \
../main.c
PREPROCESSING_SRCS +=
ASM_SRCS +=
OBJS += \
main.o
OBJS_AS_ARGS += \
main.o
C_DEPS += \
main.d
C_DEPS_AS_ARGS += \
main.d
OUTPUT_FILE_PATH +=PWM.elf
OUTPUT_FILE_PATH_AS_ARGS +=PWM.elf
ADDITIONAL_DEPENDENCIES:=
OUTPUT_FILE_DEP:= ./makedep.mk
LIB_DEP+=
LINKER_SCRIPT_DEP+=
# AVR32/GNU C Compiler
./main.o: .././main.c
@echo Building file: $<
@echo Invoking: AVR/GNU C Compiler : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega4809 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809" -c -std=gnu99 -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -o "$@" "$<"
@echo Finished building: $<
# AVR32/GNU Preprocessing Assembler
# AVR32/GNU Assembler
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all: $(OUTPUT_FILE_PATH) $(ADDITIONAL_DEPENDENCIES)
$(OUTPUT_FILE_PATH): $(OBJS) $(USER_OBJS) $(OUTPUT_FILE_DEP) $(LIB_DEP) $(LINKER_SCRIPT_DEP)
@echo Building target: $@
@echo Invoking: AVR/GNU Linker : 5.4.0
$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe$(QUOTE) -o$(OUTPUT_FILE_PATH_AS_ARGS) $(OBJS_AS_ARGS) $(USER_OBJS) $(LIBS) -Wl,-Map="PWM.map" -Wl,--start-group -Wl,-lm -Wl,--end-group -Wl,--gc-sections -mmcu=atmega4809 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809"
@echo Finished building target: $@
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "PWM.elf" "PWM.hex"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "PWM.elf" "PWM.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "PWM.elf" > "PWM.lss"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "PWM.elf" "PWM.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "PWM.elf"
# Other Targets
clean:
-$(RM) $(OBJS_AS_ARGS) $(EXECUTABLES)
-$(RM) $(C_DEPS_AS_ARGS)
rm -rf "PWM.elf" "PWM.a" "PWM.hex" "PWM.lss" "PWM.eep" "PWM.map" "PWM.srec" "PWM.usersignatures"
\ No newline at end of file
:100000000C9450000C945A000C945A000C945A0012
:100010000C945A000C945A000C945A000C945A00F8
:100020000C945A000C945A000C945A000C945A00E8
:100030000C945A000C945A000C945A000C945A00D8
:100040000C945A000C945A000C945A000C945A00C8
:100050000C945A000C945A000C945A000C945A00B8
:100060000C945A000C945A000C945A000C945A00A8
:100070000C945A000C945A000C945A000C945A0098
:100080000C945A000C945A000C945A000C945A0088
:100090000C945A000C945A000C945A000C945A0078
:1000A00011241FBECFEFCDBFDFE3DEBF0E945C0097
:1000B0000C9493000C940000789483E08093E40502
:1000C000E0E0FAE08FEF90E086A397A3808189605B
:1000D000808381858E7F8187818180628183818118
:1000E0008360818380E18093610412A613A680E07F
:1000F00090E082A793A7AFE0B7E21197F1F700C0B5
:10010000000001968F3F9105A1F78EEF282F30E078
:1001100022A733A7AFE0B7E21197F1F700C00000C4
:0A0120008150A0F7E4CFF894FFCF60
:00000001FF
PWM.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00802800 00802800 0000017e 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 0000012a 00000000 00000000 00000054 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .comment 00000030 00000000 00000000 0000017e 2**0
CONTENTS, READONLY
3 .note.gnu.avr.deviceinfo 00000040 00000000 00000000 000001b0 2**2
CONTENTS, READONLY
4 .debug_aranges 00000020 00000000 00000000 000001f0 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_info 00003335 00000000 00000000 00000210 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_abbrev 000024b4 00000000 00000000 00003545 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_line 00000360 00000000 00000000 000059f9 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_frame 00000024 00000000 00000000 00005d5c 2**2
CONTENTS, READONLY, DEBUGGING
9 .debug_str 00001674 00000000 00000000 00005d80 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_loc 00000083 00000000 00000000 000073f4 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_ranges 00000010 00000000 00000000 00007477 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
00000000 <__vectors>:
0: 0c 94 50 00 jmp 0xa0 ; 0xa0 <__ctors_end>
4: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
8: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
10: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
14: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
18: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
1c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
20: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
24: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
28: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
2c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
30: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
34: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
38: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
3c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
40: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
44: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
48: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
4c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
50: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
54: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
58: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
5c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
60: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
64: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
68: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
6c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
70: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
74: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
78: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
7c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
80: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
84: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
88: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
8c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
90: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
94: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
98: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
9c: 0c 94 5a 00 jmp 0xb4 ; 0xb4 <__bad_interrupt>
000000a0 <__ctors_end>:
a0: 11 24 eor r1, r1
a2: 1f be out 0x3f, r1 ; 63
a4: cf ef ldi r28, 0xFF ; 255
a6: cd bf out 0x3d, r28 ; 61
a8: df e3 ldi r29, 0x3F ; 63
aa: de bf out 0x3e, r29 ; 62
ac: 0e 94 5c 00 call 0xb8 ; 0xb8 <main>
b0: 0c 94 93 00 jmp 0x126 ; 0x126 <_exit>
000000b4 <__bad_interrupt>:
b4: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
000000b8 <main>:
Once we have PWM set up, controlling the brightness is super easy!
*/
int main(void)
{
sei();
b8: 78 94 sei
PORTMUX.TCAROUTEA = (0x3 << 0);
ba: 83 e0 ldi r24, 0x03 ; 3
bc: 80 93 e4 05 sts 0x05E4, r24 ; 0x8005e4 <__TEXT_REGION_LENGTH__+0x7005e4>
TCA0.SINGLE.PER = 0xff;
c0: e0 e0 ldi r30, 0x00 ; 0
c2: fa e0 ldi r31, 0x0A ; 10
c4: 8f ef ldi r24, 0xFF ; 255
c6: 90 e0 ldi r25, 0x00 ; 0
c8: 86 a3 std Z+38, r24 ; 0x26
ca: 97 a3 std Z+39, r25 ; 0x27
TCA0.SINGLE.CTRLA |= (1 << TCA_SINGLE_ENABLE_bp) | (0x4 << 1);
cc: 80 81 ld r24, Z
ce: 89 60 ori r24, 0x09 ; 9
d0: 80 83 st Z, r24
TCA0.SINGLE.EVCTRL &= ~(1 << TCA_SINGLE_CNTEI_bp);
d2: 81 85 ldd r24, Z+9 ; 0x09
d4: 8e 7f andi r24, 0xFE ; 254
d6: 81 87 std Z+9, r24 ; 0x09
TCA0.SINGLE.CTRLB |=(1 << TCA_SINGLE_CMP1EN_bp);
d8: 81 81 ldd r24, Z+1 ; 0x01
da: 80 62 ori r24, 0x20 ; 32
dc: 81 83 std Z+1, r24 ; 0x01
TCA0.SINGLE.CTRLB |= (0x03 << 0);
de: 81 81 ldd r24, Z+1 ; 0x01
e0: 83 60 ori r24, 0x03 ; 3
e2: 81 83 std Z+1, r24 ; 0x01
LED1_PORT.DIRSET = (1 << LED1);
e4: 80 e1 ldi r24, 0x10 ; 16
e6: 80 93 61 04 sts 0x0461, r24 ; 0x800461 <__TEXT_REGION_LENGTH__+0x700461>
TCA0.SINGLE.CMP1 = 0x00;
ea: 12 a6 std Z+42, r1 ; 0x2a
ec: 13 a6 std Z+43, r1 ; 0x2b
In this exercise, you will use PWM to control the brightness of LEDs
Once we have PWM set up, controlling the brightness is super easy!
*/
int main(void)
{
ee: 80 e0 ldi r24, 0x00 ; 0
f0: 90 e0 ldi r25, 0x00 ; 0
Change the brightness based on buttons
*/
for (uint8_t i = 0; i < 255; i++) {
TCA0.SINGLE.CMP1 = i;
f2: 82 a7 std Z+42, r24 ; 0x2a
f4: 93 a7 std Z+43, r25 ; 0x2b
#else
//round up by default
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
#endif
__builtin_avr_delay_cycles(__ticks_dc);
f6: af e0 ldi r26, 0x0F ; 15
f8: b7 e2 ldi r27, 0x27 ; 39
fa: 11 97 sbiw r26, 0x01 ; 1
fc: f1 f7 brne .-4 ; 0xfa <main+0x42>
fe: 00 c0 rjmp .+0 ; 0x100 <main+0x48>
100: 00 00 nop
102: 01 96 adiw r24, 0x01 ; 1
Have them fade in a pattern (Heartbeat?)
Change the brightness based on buttons
*/
for (uint8_t i = 0; i < 255; i++) {
104: 8f 3f cpi r24, 0xFF ; 255
106: 91 05 cpc r25, r1
108: a1 f7 brne .-24 ; 0xf2 <main+0x3a>
10a: 8e ef ldi r24, 0xFE ; 254
TCA0.SINGLE.CMP1 = i;
_delay_ms(2);
}
for (uint8_t i = 255; i --> 0;) {
TCA0.SINGLE.CMP1 = i;
10c: 28 2f mov r18, r24
10e: 30 e0 ldi r19, 0x00 ; 0
110: 22 a7 std Z+42, r18 ; 0x2a
112: 33 a7 std Z+43, r19 ; 0x2b
114: af e0 ldi r26, 0x0F ; 15
116: b7 e2 ldi r27, 0x27 ; 39
118: 11 97 sbiw r26, 0x01 ; 1
11a: f1 f7 brne .-4 ; 0x118 <main+0x60>
11c: 00 c0 rjmp .+0 ; 0x11e <main+0x66>
11e: 00 00 nop
for (uint8_t i = 0; i < 255; i++) {
TCA0.SINGLE.CMP1 = i;
_delay_ms(2);
}
for (uint8_t i = 255; i --> 0;) {
120: 81 50 subi r24, 0x01 ; 1
122: a0 f7 brcc .-24 ; 0x10c <main+0x54>
124: e4 cf rjmp .-56 ; 0xee <main+0x36>
00000126 <_exit>:
126: f8 94 cli
00000128 <__stop_program>:
128: ff cf rjmp .-2 ; 0x128 <__stop_program>
This diff is collapsed.
S00B000050574D2E7372656325
S11300000C9450000C945A000C945A000C945A000E
S11300100C945A000C945A000C945A000C945A00F4
S11300200C945A000C945A000C945A000C945A00E4
S11300300C945A000C945A000C945A000C945A00D4
S11300400C945A000C945A000C945A000C945A00C4
S11300500C945A000C945A000C945A000C945A00B4
S11300600C945A000C945A000C945A000C945A00A4
S11300700C945A000C945A000C945A000C945A0094
S11300800C945A000C945A000C945A000C945A0084
S11300900C945A000C945A000C945A000C945A0074
S11300A011241FBECFEFCDBFDFE3DEBF0E945C0093
S11300B00C9493000C940000789483E08093E405FE
S11300C0E0E0FAE08FEF90E086A397A38081896057
S11300D0808381858E7F8187818180628183818114
S11300E08360818380E18093610412A613A680E07B
S11300F090E082A793A7AFE0B7E21197F1F700C0B1
S1130100000001968F3F9105A1F78EEF282F30E074
S113011022A733A7AFE0B7E21197F1F700C00000C0
S10D01208150A0F7E4CFF894FFCF5C
S9030000FC
main.d main.o: .././main.c \
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\inttypes.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\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\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom4809.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\xmega.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h \
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.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\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\sfr_defs.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\inttypes.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\lib\gcc\avr\5.4.0\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\Packs\atmel\ATmega_DFP\1.2.209\include/avr/iom4809.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\portpins.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\common.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\version.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\xmega.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\fuse.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\lock.h:
c:\program\ files\ (x86)\atmel\studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\util\delay.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\avr\interrupt.h:
################################################################################
# Automatically-generated file. Do not edit or delete the file
################################################################################
main.c
<?xml version="1.0" encoding="utf-8"?>
<Store xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="AtmelPackComponentManagement">
<ProjectComponents>
<ProjectComponent z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<CApiVersion></CApiVersion>
<CBundle></CBundle>
<CClass>Device</CClass>
<CGroup>Startup</CGroup>
<CSub></CSub>
<CVariant></CVariant>
<CVendor>Atmel</CVendor>
<CVersion>1.2.0</CVersion>
<DefaultRepoPath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs</DefaultRepoPath>
<DependentComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" />
<Description></Description>
<Files xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include</AbsolutePath>
<Attribute></Attribute>
<Category>include</Category>
<Condition>C</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>include</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\include\avr\iom4809.h</AbsolutePath>
<Attribute></Attribute>
<Category>header</Category>
<Condition>C</Condition>
<FileContentHash>mWiFIOAGwUPlW0rYsXcjkg==</FileContentHash>
<FileVersion></FileVersion>
<Name>include/avr/iom4809.h</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\templates\main.c</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>Gr1V4OXjfuHfBs+wJalHbQ==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.c</Name>
<SelectString>Main file (.c)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\templates\main.cpp</AbsolutePath>
<Attribute>template</Attribute>
<Category>source</Category>
<Condition>C Exe</Condition>
<FileContentHash>YXFphlh0CtZJU+ebktABgQ==</FileContentHash>
<FileVersion></FileVersion>
<Name>templates/main.cpp</Name>
<SelectString>Main file (.cpp)</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType i:type="FileInfo">
<AbsolutePath>C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.209\gcc\dev\atmega4809</AbsolutePath>
<Attribute></Attribute>
<Category>libraryPrefix</Category>
<Condition>GCC</Condition>
<FileContentHash i:nil="true" />
<FileVersion></FileVersion>
<Name>gcc/dev/atmega4809</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>ATmega_DFP</PackName>
<PackPath>C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.209/Atmel.ATmega_DFP.pdsc</PackPath>
<PackVersion>1.2.209</PackVersion>
<PresentInProject>true</PresentInProject>
<ReferenceConditionId>ATmega4809</ReferenceConditionId>
<RteComponents xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string></d4p1:string>
</RteComponents>
<Status>Resolved</Status>
<VersionMode>Fixed</VersionMode>
<IsComponentInAtProject>true</IsComponentInAtProject>
</ProjectComponent>
</ProjectComponents>
</Store>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<ProjectVersion>7.0</ProjectVersion>
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
<ProjectGuid>dce6c7e3-ee26-4d79-826b-08594b9ad897</ProjectGuid>
<avrdevice>ATmega4809</avrdevice>
<avrdeviceseries>none</avrdeviceseries>
<OutputType>Executable</OutputType>
<Language>C</Language>