Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
avrkurs
avrkurs
Commits
65f56d48
Commit
65f56d48
authored
Feb 17, 2019
by
BuildTools
Browse files
Fixed tasks until PWM, whcih dosent work
parent
55bcbee3
Pipeline
#243
failed with stages
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Session1-LF/Task1-LF.c
View file @
65f56d48
/*
* Task1
-LF
.c
* Task1.c
*
* Created:
29
.0
1
.2017 23:
43:39
* Created:
11
.0
2
.2017 23:
37:53
* Author : Petter
*/
/**
* F_CPU tells the timer what the CPU's clock frequency is, such that the timer will count correctly.
* Note that this DOES NOT set the clock speed, it just informs the timer.
...
...
@@ -13,7 +15,7 @@
* F_CPU must be defined before including headers.
*/
#define F_CPU 3333333UL //The ATtiny
817
operates at 20MHz with a default scaling factor of 6: 20/6 = 3.333333MHz
#define F_CPU 3333333UL //The ATtiny
4809
operates at 20MHz with a default scaling factor of 6: 20/6 = 3.333333MHz
/**
* System headers bellow
...
...
@@ -24,26 +26,31 @@
/**
* Define helpers for pin bit positions.
* The LED0 on the AT
mega324PB
main board is connected to pin 4 on port
B
.
* The LED0 on the AT
tiny4809
main board is connected to pin 4 on port
D
.
* Check the datasheet to find out which pins on which ports the different LEDs and buttons are connected to.
*/
#define LED0 4 // LED0 is connected to pin 4 on port B (PIN4_bp)
#define LED0 4 // LED 1 is connected to pin 4 on PORTD
int
main
(
void
){
/**
* We want to send signals to the LEDs, in order to turn the off and on.
* In the AVR world we have the following:
* PORTx
_
DIR: 1 is output, 0 is input
* PORTx
.
DIR: 1 is output, 0 is input
* LED: 1 LED is off, 0 LED is on, this is called active-low
* Button: 1 button is open, 0 button is pressed, this is called active-low
*
* Remember bit set logic:
* Set to 1: FLAG |= ( 1 << BIT_POS ) - using 'or' so we only change the one we want and leave the others untouched
* Set to 0: FLAG &= ~( 1 << BIT_POS ) - same thing here but using 'and', find paper and a logic-table, and try it out if you want to know how it works
* Set to 1: FLAG |= ( 1 << BIT_POS ) - using 'or' so we only change the one we want and leave the others untouched
* Set to 0: FLAG &= ~( 1 << BIT_POS ) - same thing here but using 'and', find paper and a logic-table, and try it out if you want to know how it works
* Toogle bit: FLAG ^= ( 1 << BIT_POS ) - using bitwise xor, toogles the bit at BIT_POS
*/
PORT
B
.
DIR
|=
(
1
<<
LED0
);
// Set LED0 as output - Using "
B
" in PORTx.DIR since the LED is connected to port
B
on the microcontroller
PORT
D
.
DIR
|=
(
1
<<
LED0
);
// Set LED0 as output - Using "
D
" in PORTx.DIR since the LED is connected to port
D
on the microcontroller
/*
* The usual way to run microcontrollers is using a simple infinite loop
...
...
@@ -51,8 +58,9 @@ int main(void){
while
(
1
)
{
PORTB
.
OUT
^=
(
1
<<
LED0
);
// Changes the state of LED0 by XOR-ing the last state. Check the XOR-table to find out how this works.
// Non-compressed: PORTB_OUT = PORTB.OUT ^ (1 << LED0);
PORTD
.
OUT
^=
(
1
<<
LED0
);
// Changes the state of LED0 by XOR-ing the last state. Check the XOR-table to find out how this works.
// Non-compressed: PORTD.OUT = PORTD.OUT ^ (1 << LED0);
//Can also refer to toogle register: PORTD.OUTTGL = (1 << LED0). IMPORTANT: only use equal sign here (=)
_delay_ms
(
500
);
}
}
Session1-LF/Task2-LF.c
View file @
65f56d48
/*
* Task2
-LF
.c
* Task2.c
*
* Created:
29
.0
1
.2017 23:
43:39
* Created:
11
.0
2
.2017 23:
39:47
* Author : Petter
*/
...
...
@@ -15,59 +15,74 @@
#include <util/delay.h>
/*
* Checkout the ATtiny
817
datasheet to find the correct ports and pins
* Check
out the ATtiny
4809
datasheet to find the correct ports and pins
*/
// LED
#define LED0 4 //On port
B
#define LED0 4 //On port
D
// Button
#define SW0
5
//On port
B
#define SW0
2
//On port
C
int
main
(
void
)
{
/*
* We want to send signals to the LEDs, in order to turn it off and on.
* We also want to be able to read the switches.
* This is done by setting bits in the PORTx.DIR register (in this case PORT
B
.DIR)
* This is done by setting bits in the PORTx.DIR register (in this case PORT
D.DIR and PORTC
.DIR)
* PORTx.DIR: 1 is output, 0 is input
* LED: 1 LED is off, 0 LED is on
* Button: 1 Button is open, 0 button is pressed
* Bit set logic:
* Set to 1:
FLA
G |= ( 1 << BIT_POS )
* Set to 0:
FLA
G &= ~( 1 << BIT_POS )
* Set to 1:
RE
G |= ( 1 << BIT_POS )
* Set to 0:
RE
G &= ~( 1 << BIT_POS )
*/
/**
* In order to read from the switches, we need to give it a ground reference, via a pull-up resistor.
* If we don't, the switch will have a floating ground, and hence its value will be undefined.
* On the ATtiny817, we enable pull-up by setting the "PORT_PULLUPEN_bp" flag in "PORTx.PINnCTRL" high.
* See datasheet section 16 (I/O-ports) and user guide section 4 (Hardware User Guide).
* On the ATtiny4809, we enable pull-up by setting the "PORT_PULLUPEN" flag in "PORTx.PINnCTRL" high.
* See datasheet section 15 (I/O-ports).
*/
/*
* It's your time to do some stuff! Do the following:
* 1 - Set LED0 as output
* 2 - Set SW0 as input
* 3 - Enable pull-up on button SW0
*/
PORTB
.
DIR
|=
(
1
<<
LED0
);
// Set LED0 as output
PORTB
.
DIR
&=
~
(
1
<<
SW0
);
//Set SW0 as input
PORTB
.
PIN5CTRL
|=
(
1
<<
PORT_PULLUPEN_bp
);
//Enable pull-up on button SW0 (pin5)
PORTD
.
DIR
|=
(
1
<<
LED0
);
// Set LED0 as output
PORTC
.
DIR
&=
~
(
1
<<
SW0
);
//Set SW0 as input
PORTB
.
PIN2CTRL
|=
(
1
<<
PORT_PULLUPEN_bp
);
//Enable pull-up on button SW0 (pin5)
while
(
1
)
{
/*
* Here, you want to check if a button is pressed, and if yes, turn on the LED.
* If no, then do the opposite.
* Similar to setting pins with PORTx
_
OUT, we can read pins with PORTx.IN
* Similar to setting pins with PORTx
.
OUT, we can read pins with PORTx.IN
* In order to check a pin value, mask out that particular bit. (use bitwise AND)
* Bit masking is done like this:
* (REGISTER & (1 << BIT_POS)), which selects bit BIT_POS from register.
* If that bit is 0, the result will be 0. If it is 1, the result will be other than 0 (depending on bit pos).
*/
if
(
!
(
PORTB
.
IN
&
(
1
<<
SW0
))){
// If button is pressed (0 - LOW
PORTB
.
OUT
&=
~
(
1
<<
LED0
);
// Sets output to 0, turns LED0 on
/*
* Do the following:
* 1 - check if button SW0 is pressed
* 2 - if so, turn the LED on
* 3 - if not, turn the LED off
*/
if
(
!
(
PORTC
.
IN
&
(
1
<<
SW0
))){
// If button is pressed (0 - LOW
PORTD
.
OUT
&=
~
(
1
<<
LED0
);
// Sets output to 0, turns LED0 on
}
else
{
PORT
B
.
OUT
|=
(
1
<<
LED0
);
// Sets output to 1, turns LED off
PORT
D
.
OUT
|=
(
1
<<
LED0
);
// Sets output to 1, turns LED off
}
}
...
...
Session1-LF/Task3-LF.c
View file @
65f56d48
...
...
@@ -12,10 +12,10 @@
#include <stdbool.h>
//LED
#define LED0 4 //on port
B
#define LED0 4 //on port
D
//Button
#define SW0
5
//on port
B
#define SW0
2
//on port
C
int
main
(
void
)
{
...
...
@@ -29,10 +29,10 @@ int main(void)
* Set to 0: REG &= ~( 1 << BIT_POS )
* This is called "read-modify-write".
*
* The ATtiny
817
also has special port registers that can do some of this for you.
* The ATtiny
4809
also has special port registers that can do some of this for you.
* Read what PORTx.DIRSET, .DIRCLR and .DIRTGL do to the PORTx.DIR register,
* And similarly what PORTx.OUTSET, .OUTCLR and .OUTTGL do to PORTx.OUT
* (HINT: see chapter 1
6
.5 of the datasheet)
* (HINT: see chapter 1
5
.5 of the datasheet)
LF: They set clear and toggle bit in the register. eks: PORTB.DIRCLR = (1 << 5); to clear bit 5
...
...
@@ -40,13 +40,16 @@ int main(void)
*/
PORTB
.
DIRSET
=
(
1
<<
LED0
);
// Set LED0 as output
//Alt: PORTB.DIR |= (1 << LED0);
PORTD
.
DIRSET
=
(
1
<<
LED0
);
// Set LED0 as output
//Alt: PORTD.DIR |= (1 << LED0);
PORTD
.
OUTSET
=
(
1
<<
LED0
);
// Set LED0 output high (turns off the led, since the led is active low)
//Alt: PORTD.OUT |= (1 << LED0);
PORT
B
.
DIRCLR
=
(
1
<<
SW0
);
// Set SW0 as input (default)
//Alt: PORT
B
.DIR &= ~(1 << SW0);
PORT
C
.
DIRCLR
=
(
1
<<
SW0
);
// Set SW0 as input (default)
//Alt: PORT
C
.DIR &= ~(1 << SW0);
PORT
B
.
PIN
5
CTRL
|=
(
1
<<
3
);
// Enable pull-up on button SW
PORT
C
.
PIN
2
CTRL
|=
(
1
<<
3
);
// Enable pull-up on button SW
//eller bruk PORT_PULLUPEN_bp som er lik 3 (_bp = Bit Position)
...
...
@@ -54,11 +57,11 @@ int main(void)
while
(
1
)
{
if
(
!
(
PORT
B
.
IN
&
(
1
<<
SW0
))){
if
(
!
(
PORT
C
.
IN
&
(
1
<<
SW0
))){
if
(
buttonState
==
0
){
PORT
B
.
OUTTGL
=
(
1
<<
LED0
);
//Alt: PORT
B
.OUT ^= (1 << LED0);
PORT
D
.
OUTTGL
=
(
1
<<
LED0
);
//Alt: PORT
D
.OUT ^= (1 << LED0);
buttonState
=
1
;
}
...
...
Session1/Task1/Task1.componentinfo.xml
View file @
65f56d48
...
...
@@ -9,13 +9,13 @@
<CSub></CSub>
<CVariant></CVariant>
<CVendor>
Atmel
</CVendor>
<CVersion>
1.
1
.0
</CVersion>
<DefaultRepoPath>
D
:/
Atmel
\7.0\Packs
</DefaultRepoPath>
<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>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\include
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\include
</AbsolutePath>
<Attribute></Attribute>
<Category>
include
</Category>
<Condition>
C
</Condition>
...
...
@@ -26,29 +26,29 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\include\avr\io
tn817
.h
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\include\avr\io
m4809
.h
</AbsolutePath>
<Attribute></Attribute>
<Category>
header
</Category>
<Condition>
C
</Condition>
<FileContentHash>
GzsE/dwQAz37AkZENa/sH
g==
</FileContentHash>
<FileContentHash>
mWiFIOAGwUPlW0rYsXcjk
g==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
include/avr/io
tn817
.h
</Name>
<Name>
include/avr/io
m4809
.h
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\templates\main.c
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\templates\main.c
</AbsolutePath>
<Attribute>
template
</Attribute>
<Category>
source
</Category>
<Condition>
C Exe
</Condition>
<FileContentHash>
NtrFFJHqGYFgQ+e154IDwQ
==
</FileContentHash>
<FileContentHash>
GD1k8YYhulqRs6FD1B2Hog
==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
templates/main.c
</Name>
<SelectString>
Main file (.c)
</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\templates\main.cpp
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\templates\main.cpp
</AbsolutePath>
<Attribute>
template
</Attribute>
<Category>
source
</Category>
<Condition>
C Exe
</Condition>
...
...
@@ -59,22 +59,22 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\gcc\dev\at
tiny817
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\gcc\dev\at
mega4809
</AbsolutePath>
<Attribute></Attribute>
<Category>
libraryPrefix
</Category>
<Condition>
GCC
</Condition>
<FileContentHash
i:nil=
"true"
/>
<FileVersion></FileVersion>
<Name>
gcc/dev/at
tiny817
</Name>
<Name>
gcc/dev/at
mega4809
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>
AT
tiny
_DFP
</PackName>
<PackPath>
D
:/
Atmel
/7.0/Packs/atmel/AT
tiny
_DFP/1.
1.102
/Atmel.AT
tiny
_DFP.pdsc
</PackPath>
<PackVersion>
1.
1.102
</PackVersion>
<PackName>
AT
mega
_DFP
</PackName>
<PackPath>
C
:/
Program Files (x86)/Atmel/Studio
/7.0/Packs/atmel/AT
mega
_DFP/1.
2.209
/Atmel.AT
mega
_DFP.pdsc
</PackPath>
<PackVersion>
1.
2.209
</PackVersion>
<PresentInProject>
true
</PresentInProject>
<ReferenceConditionId>
AT
tiny817
</ReferenceConditionId>
<ReferenceConditionId>
AT
mega4809
</ReferenceConditionId>
<RteComponents
xmlns:d4p1=
"http://schemas.microsoft.com/2003/10/Serialization/Arrays"
>
<d4p1:string></d4p1:string>
</RteComponents>
...
...
Session1/Task1/Task1.cproj
View file @
65f56d48
...
...
@@ -5,7 +5,7 @@
<ProjectVersion>
7.0
</ProjectVersion>
<ToolchainName>
com.Atmel.AVRGCC8.C
</ToolchainName>
<ProjectGuid>
dce6c7e3-ee26-4d79-826b-08594b9ad897
</ProjectGuid>
<avrdevice>
AT
tiny817
</avrdevice>
<avrdevice>
AT
mega4809
</avrdevice>
<avrdeviceseries>
none
</avrdeviceseries>
<OutputType>
Executable
</OutputType>
<Language>
C
</Language>
...
...
@@ -20,29 +20,71 @@
<OverrideVtor>
false
</OverrideVtor>
<CacheFlash>
true
</CacheFlash>
<ProgFlashFromRam>
true
</ProgFlashFromRam>
<RamSnippetAddress
/
>
<RamSnippetAddress
>
0x20000000
</RamSnippetAddress
>
<UncachedRange
/>
<preserveEEPROM>
true
</preserveEEPROM>
<OverrideVtorValue
/
>
<OverrideVtorValue
>
exception_table
</OverrideVtorValue
>
<BootSegment>
2
</BootSegment>
<eraseonlaunchrule>
0
</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data
xmlns=
""
>
<framework-data>
<options
/>
<configurations
/>
<files
/>
<documentation
help=
""
/>
<offline-documentation
help=
""
/>
<dependencies>
<content-extension
eid=
"atmel.asf"
uuidref=
"Atmel.ASF"
version=
"3.3
2.0
"
/>
<content-extension
eid=
"atmel.asf"
uuidref=
"Atmel.ASF"
version=
"3.3
4.1
"
/>
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<ResetRule>
0
</ResetRule>
<EraseKey
/>
<avrtool>
com.atmel.avrdbg.tool.nedbg
</avrtool>
<avrtoolserialnumber>
ATML3094051800000431
</avrtoolserialnumber>
<avrdeviceexpectedsignature>
0x1E9651
</avrdeviceexpectedsignature>
<custom>
<ToolOptions>
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>
</InterfaceName>
</ToolOptions>
<ToolType>
custom
</ToolType>
<ToolNumber>
</ToolNumber>
<ToolName>
Custom Programming Tool
</ToolName>
</custom>
<avrtoolinterface>
UPDI
</avrtoolinterface>
<com_atmel_avrdbg_tool_simulator>
<ToolOptions
xmlns=
""
>
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>
</InterfaceName>
</ToolOptions>
<ToolType
xmlns=
""
>
com.atmel.avrdbg.tool.simulator
</ToolType>
<ToolNumber
xmlns=
""
>
</ToolNumber>
<ToolName
xmlns=
""
>
Simulator
</ToolName>
</com_atmel_avrdbg_tool_simulator>
<com_atmel_avrdbg_tool_nedbg>
<ToolOptions>
<InterfaceProperties>
<UpdiClock>
750000
</UpdiClock>
</InterfaceProperties>
<InterfaceName>
UPDI
</InterfaceName>
</ToolOptions>
<ToolType>
com.atmel.avrdbg.tool.nedbg
</ToolType>
<ToolNumber>
ATML3094051800000431
</ToolNumber>
<ToolName>
nEDBG
</ToolName>
</com_atmel_avrdbg_tool_nedbg>
<avrtoolinterfaceclock>
750000
</avrtoolinterfaceclock>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)' == 'Release' "
>
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>
-mmcu=at
tiny817
-B "%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\gcc\dev\at
tiny817
"
</avrgcc.common.Device>
<avrgcc.common.Device>
-mmcu=at
mega4809
-B "%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\gcc\dev\at
mega4809
"
</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>
True
</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>
True
</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>
True
</avrgcc.common.outputfiles.eep>
...
...
@@ -57,7 +99,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>
%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\include
</Value>
<Value>
%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\include
</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>
Optimize for size (-Os)
</avrgcc.compiler.optimization.level>
...
...
@@ -71,7 +113,7 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>
%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\include
</Value>
<Value>
%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\include
</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
</AvrGcc>
...
...
@@ -80,7 +122,7 @@
<PropertyGroup
Condition=
" '$(Configuration)' == 'Debug' "
>
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>
-mmcu=at
tiny817
-B "%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\gcc\dev\at
tiny817
"
</avrgcc.common.Device>
<avrgcc.common.Device>
-mmcu=at
mega4809
-B "%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\gcc\dev\at
mega4809
"
</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>
True
</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>
True
</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>
True
</avrgcc.common.outputfiles.eep>
...
...
@@ -95,7 +137,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>
%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\include
</Value>
<Value>
%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\include
</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>
Optimize (-O1)
</avrgcc.compiler.optimization.level>
...
...
@@ -110,7 +152,7 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>
%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\include
</Value>
<Value>
%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\include
</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>
Default (-Wa,-g)
</avrgcc.assembler.debugging.DebugLevel>
...
...
Session1/Task1/main.c
View file @
65f56d48
...
...
@@ -14,7 +14,7 @@
* F_CPU must be defined before including headers.
*/
#define F_CPU 3333333UL //The ATtiny
817
operates at 20MHz with a default scaling factor of 6: 20/6 = 3.333333MHz
#define F_CPU 3333333UL //The ATtiny
4809
operates at 20MHz with a default scaling factor of 6: 20/6 = 3.333333MHz
/**
* System headers bellow
...
...
@@ -25,11 +25,15 @@
/**
* Define helpers for pin bit positions.
* The LED0 on the ATtiny
817
main board is connected to pin 4 on port
B
.
* The LED0 on the ATtiny
4809
main board is connected to pin 4 on port
D
.
* Check the datasheet to find out which pins on which ports the different LEDs and buttons are connected to.
*/
#define LED0 4 // LED0 is connected to pin 4 on port B
#define LED0 4 // LED 1 is connected to pin 4 on PORTD
int
main
(
void
){
/**
...
...
@@ -40,11 +44,12 @@ int main(void){
* Button: 1 button is open, 0 button is pressed, this is called active-low
*
* Remember bit set logic:
* Set to 1: FLAG |= ( 1 << BIT_POS ) - using 'or' so we only change the one we want and leave the others untouched
* Set to 0: FLAG &= ~( 1 << BIT_POS ) - same thing here but using 'and', find paper and a logic-table, and try it out if you want to know how it works
* Set to 1: FLAG |= ( 1 << BIT_POS ) - using 'or' so we only change the one we want and leave the others untouched
* Set to 0: FLAG &= ~( 1 << BIT_POS ) - same thing here but using 'and', find paper and a logic-table, and try it out if you want to know how it works
* Toogle bit: FLAG ^= ( 1 << BIT_POS ) - using bitwise xor, toogles the bit at BIT_POS
*/
PORT
B
.
DIR
|=
(
1
<<
LED0
);
// Set LED0 as output - Using "
B
" in PORTx.DIR since the LED is connected to port
B
on the microcontroller
PORT
D
.
DIR
|=
(
1
<<
LED0
);
// Set LED0 as output - Using "
D
" in PORTx.DIR since the LED is connected to port
D
on the microcontroller
/*
* The usual way to run microcontrollers is using a simple infinite loop
...
...
@@ -52,8 +57,9 @@ int main(void){
while
(
1
)
{
PORTB
.
OUT
^=
(
1
<<
LED0
);
// Changes the state of LED0 by XOR-ing the last state. Check the XOR-table to find out how this works.
// Non-compressed: PORTB.OUT = PORTB.OUT ^ (1 << LED0);
PORTD
.
OUT
^=
(
1
<<
LED0
);
// Changes the state of LED0 by XOR-ing the last state. Check the XOR-table to find out how this works.
// Non-compressed: PORTD.OUT = PORTD.OUT ^ (1 << LED0);
//Can also refer to toogle register: PORTD.OUTTGL = (1 << LED0). IMPORTANT: only use equal sign here (=)
_delay_ms
(
500
);
}
}
Session1/Task2/Task2.componentinfo.xml
View file @
65f56d48
...
...
@@ -9,13 +9,13 @@
<CSub></CSub>
<CVariant></CVariant>
<CVendor>
Atmel
</CVendor>
<CVersion>
1.
1
.0
</CVersion>
<DefaultRepoPath>
D
:/
Atmel
\7.0\Packs
</DefaultRepoPath>
<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>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\include
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\include
</AbsolutePath>
<Attribute></Attribute>
<Category>
include
</Category>
<Condition>
C
</Condition>
...
...
@@ -26,29 +26,29 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\include\avr\io
tn817
.h
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\include\avr\io
m4809
.h
</AbsolutePath>
<Attribute></Attribute>
<Category>
header
</Category>
<Condition>
C
</Condition>
<FileContentHash>
GzsE/dwQAz37AkZENa/sH
g==
</FileContentHash>
<FileContentHash>
mWiFIOAGwUPlW0rYsXcjk
g==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
include/avr/io
tn817
.h
</Name>
<Name>
include/avr/io
m4809
.h
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\templates\main.c
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\templates\main.c
</AbsolutePath>
<Attribute>
template
</Attribute>
<Category>
source
</Category>
<Condition>
C Exe
</Condition>
<FileContentHash>
9Sja2uJ3CnNJ4jsn5JQvZw
==
</FileContentHash>
<FileContentHash>
GD1k8YYhulqRs6FD1B2Hog
==
</FileContentHash>
<FileVersion></FileVersion>
<Name>
templates/main.c
</Name>
<SelectString>
Main file (.c)
</SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\templates\main.cpp
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\templates\main.cpp
</AbsolutePath>
<Attribute>
template
</Attribute>
<Category>
source
</Category>
<Condition>
C Exe
</Condition>
...
...
@@ -59,22 +59,22 @@
<SourcePath></SourcePath>
</d4p1:anyType>
<d4p1:anyType
i:type=
"FileInfo"
>
<AbsolutePath>
D
:/
Atmel
\7.0\Packs\atmel\AT
tiny
_DFP\1.
1.102
\gcc\dev\at
tiny817
</AbsolutePath>
<AbsolutePath>
C
:/
Program Files (x86)\Atmel\Studio
\7.0\Packs\atmel\AT
mega
_DFP\1.
2.209
\gcc\dev\at
mega4809
</AbsolutePath>
<Attribute></Attribute>
<Category>
libraryPrefix
</Category>
<Condition>
GCC
</Condition>
<FileContentHash
i:nil=
"true"
/>
<FileVersion></FileVersion>
<Name>
gcc/dev/at
tiny817
</Name>
<Name>
gcc/dev/at
mega4809
</Name>
<SelectString></SelectString>
<SourcePath></SourcePath>
</d4p1:anyType>
</Files>
<PackName>
AT
tiny
_DFP
</PackName>
<PackPath>
D
:/
Atmel
/7.0/Packs/atmel/AT
tiny
_DFP/1.
1.102
/Atmel.AT
tiny
_DFP.pdsc
</PackPath>
<PackVersion>
1.
1.102
</PackVersion>
<PackName>
AT
mega
_DFP
</PackName>
<PackPath>
C
:/
Program Files (x86)/Atmel/Studio
/7.0/Packs/atmel/AT
mega
_DFP/1.
2.209
/Atmel.AT
mega
_DFP.pdsc
</PackPath>
<PackVersion>
1.
2.209
</PackVersion>
<PresentInProject>
true
</PresentInProject>
<ReferenceConditionId>
AT
tiny817
</ReferenceConditionId>
<ReferenceConditionId>
AT
mega4809
</ReferenceConditionId>
<RteComponents
xmlns:d4p1=
"http://schemas.microsoft.com/2003/10/Serialization/Arrays"
>
<d4p1:string></d4p1:string>
</RteComponents>
...
...
Session1/Task2/Task2.cproj
View file @
65f56d48
...
...
@@ -5,7 +5,7 @@
<ProjectVersion>
7.0
</ProjectVersion>
<ToolchainName>
com.Atmel.AVRGCC8.C
</ToolchainName>
<ProjectGuid>
dce6c7e3-ee26-4d79-826b-08594b9ad897
</ProjectGuid>
<avrdevice>
AT
tiny817
</avrdevice>
<avrdevice>
AT
mega4809
</avrdevice>
<avrdeviceseries>
none
</avrdeviceseries>
<OutputType>
Executable
</OutputType>
<Language>
C
</Language>
...
...
@@ -27,22 +27,25 @@
<BootSegment>
2
</BootSegment>
<eraseonlaunchrule>
0
</eraseonlaunchrule>
<AsfFrameworkConfig>
<framework-data
xmlns=
""
>
<framework-data>
<options
/>
<configurations
/>
<files
/>
<documentation
help=
""
/>
<offline-documentation
help=
""
/>
<dependencies>
<content-extension
eid=
"atmel.asf"
uuidref=
"Atmel.ASF"
version=
"3.3
2.0
"
/>
<content-extension
eid=
"atmel.asf"
uuidref=
"Atmel.ASF"
version=
"3.3
4.1
"
/>
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<ResetRule>
0
</ResetRule>
<EraseKey
/>
<avrtool
/>
</PropertyGroup>
<PropertyGroup
Condition=
" '$(Configuration)' == 'Release' "
>
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>
-mmcu=at
tiny817
-B "%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\gcc\dev\at
tiny817
"
</avrgcc.common.Device>
<avrgcc.common.Device>
-mmcu=at
mega4809
-B "%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\gcc\dev\at
mega4809
"
</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>
True
</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>
True
</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>
True
</avrgcc.common.outputfiles.eep>
...
...
@@ -57,7 +60,7 @@
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>
%24(PackRepoDir)\atmel\AT
tiny
_DFP\1.
1.102
\include
</Value>
<Value>
%24(PackRepoDir)\atmel\AT
mega
_DFP\1.
2.209
\include
</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>
Optimize for size (-Os)
</avrgcc.compiler.optimization.level>
...
...
@@ -71,7 +74,7 @@
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>