RSGC ACES: AVR8 Assembly Language Fundamentals (last update: 2021 04 09) |
The Goal
Life involves tradeoffs and, after taking the most important ones for our purposes into consideration, it is time to retire the Arduino IDE, in favour of ATMEL Studio 7.0 (AS7) for your embedded assembly language solutions. AS7 suite of tools offers strong support for debugging while allowing us to continue to develop on the DDP with the Sparkfun Pocket Programmer based on the USBtiny protocol.
Finally, I do not need to remind you these concepts are tough sledding but, you'll soon appreciate how happy you are to have had this introduction when your future peers are swamped a few short years from now. (DDBv6 with SoftwareSerial support appears to the right)
References
The sequence of exercises below have been carefully crafted for your (possible) future as a computer engineer. Commit yourself and reap the rewards.
;PROJECT :BareMinimum84 ;PURPOSE :Code shell for AVR Assembly projects for the DDP (ATtiny84) ;AUTHOR :C. Darcy ;DATE :2020 03 24 ;DEVICE :Dolgin Development Platform ;MCU :ATtiny84 ;COURSE :ICS4U ;STATUS :??? ;REFERENCE :https://mail.rsgc.on.ca/~cdarcy/Datasheets/doc0856.pdf ;NOTES : ;.include "prescalars.inc" ;assembly directive equivalent to compiler directive #include .def util = r16 ;readability is enhanced through 'use' aliases for GP Registers .equ DDR = DDRA ;typically, we'll need the use of PortA .equ PORT = PORTA ;both its data direction register and output register and, eventually, .equ PIN = PINA ;its input register ; DATA Segment declarations .dseg ;locate for Data Segment (SRAM) requirements (default start at 0x0060) var: .BYTE 1 ;reserve one byte for a variable (the label is the symbol) ; CODE Segment (default) .cseg ;locate for Code Segment (FLASH) ; ***** INTERRUPT VECTOR TABLE *********************************************** .org 0x0000 ;start of Interrupt Vector Table (IVT) aka. Jump Table rjmp reset ;lowest interrupt address == highest priority! .org EXT_INT0addr ;External Interrupt Request 0 (prefined in tn84def.inc) ; rjmp INT0_vect ; ***** START OF CODE ******************************************************** .org 0x0100 ;well clear of IVT reset: ;PC jumps to here (start of code) on reset interrupt... wait: ldi util,0xAA sts var,util rjmp wait ;repeat or hold...
Activity: Project Template Creation in 3 Steps
Step 1. First, we need to create and explore an assembly code shell that will serve a role similar to the BareMinimum
sketch we used repeatedly in the Arduino IDE.
Assembly
folder with the name BareMinimum84
.main.asm
code supplied and listen carefully as we review it.tn84def.inc
file to review the complete list of .equates
available to your assembly code. You are encouraged to maximize their use.main.asm
, select Export Template... under the File menu.BareMinimum84
as the Template Name. BareMinimum84
template, providing a more productive use of your time and effort.Activity: Bicolor Confirmation
For the exercises below, before we add the AVR Assembly complexities of serial IO, we'll find it simpler to have a bicolor LED (spanning the digital pins PA0
and PA1
) to signal digital 0 or 1 or the success (or failure) of a particular assembly programming test.
Let's explore what it takes to display the two different colours on the bicolor LED. See ATtiny84 Register Summary.
Assembly
folder, create a project called BicolorConfirmation
, based on your BareMinimum84
template.main
function, declare digital pins 0 and 1 only, for output.red
, green
, and LEDOff
functions that achieve their expected results.reset
function to confirm the correct performance of the three functions.delay
function as you did earlier in the course (AVR Delay Loop Calculator).If..then..else Statement in AVR Assembly