Skip to content

Instantly share code, notes, and snippets.

View BobBurns's full-sized avatar

Bob Burns BobBurns

  • Santa Cruz, CA
View GitHub Profile
@BobBurns
BobBurns / cylonEyes.asm
Created November 13, 2014 01:08
assembly version of cylon eyes from Elliot Williams AVR Programming
;assembly version of Cylon Eyes p.60
;compile with gavrasm cylonEyes.asm
;
;--- set up ---
.device atmega168
.cseg
.org 0
.def delayH =r25
.def delayL =r24
.def led =r16
@BobBurns
BobBurns / showBits.asm
Created November 14, 2014 05:28
another assembly version of Elliot Williams AVR Programming. Chapter 4
;showingOffBits assembly version
;
;compile with gavrasm showBits.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.XXXXXXX -b 19200 -U flash:w:showBits.hex
;--- set up ---
.device atmega168
.cseg
.org 0
.def delayH =r25
.def delayL =r24
@BobBurns
BobBurns / serial_assembly.asm
Created November 14, 2014 20:45
serialLoopback.c program from Elliot Williams AVR Programming written in avr assembly
;serial io echo program from AVR Programming p.81 by Elliot Williams
;help from T. Margush Some Assembly Required
;compile with gavrasm serial_assembly.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.XXXXXXX -b 19200 -U flash:w:serial_assembly.hex
;
; cpu_f = 1,000,000 baud = 9600 use 2x(USX0 = 1)
;Programmer: Me
;2 mhz clock speed, 9600 baud UBBR = 12
.equ UBBRvalue = 12
.equ UCSR0C = 0xc2 ; SRAM address of UCSR0C
@BobBurns
BobBurns / serial_assembly2.asm
Created November 15, 2014 00:29
Hello World - even better version of serial_assembly.asm
;serial io echo program from AVR Programming p.81 by Elliot Williams
;help from T. Margush Some Assembly Required
;compile with gavrasm serial_assembly.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:serial_assembly.hex
;
; cpu_f = 1,000,000 baud = 9600 use 2x(USX0 = 1)
;Programmer: Me
;2 mhz clock speed, 9600 baud UBBR = 12
.equ UBBRvalue = 12
.equ UCSR0C = 0xc2 ; SRAM address of UCSR0C
@BobBurns
BobBurns / organAssembly.asm
Created November 18, 2014 00:55
AVR assembly program to toggle a speaker from USART serial connection. Based on serialOrgan.c from E.Williams AVR Programming p.100
;Serial Organ program p.100
;compile with gavrasm organAssembly.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:organAssembly.hex;
;USART configure: 2x 1Mhz clock speed, 9600 baud UBBR = 12
.equ UBBRvalue = 12
.def temp = r16
.def zL = r30
.def zH = r31 ;not defined
.def byte_tx = r18
.def inB = r20
@BobBurns
BobBurns / debouncer.asm
Created November 20, 2014 00:27
AVR Assembly simple debouncer
;example program using debouncing
;from AVR Programming by Elliot Williams p.115
;
;compile with gavrasm debouncer.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:debouncer.hex
;
.def temp = r16
.device atmega168
;--- inits ---
.def b_pressed = r17
@BobBurns
BobBurns / lightMeter.asm
Created November 21, 2014 14:48
light metering program in avr assembly
;Light Meter assembly version
;based on E.Williams AVR Programming lightSensor.c p.135
;compile with gavrasm lightMeter.asm
;
.device atmega 168
.cseg
.org 0
.def temp = r16
;--- Inits ---
ldi temp,0xff
@BobBurns
BobBurns / lightLight.asm
Created November 22, 2014 13:44
AVR Assembly program using adc, the multiplexer, and sram for variable data
;Night Light program from p.148
;
;example program using adc, mux, and sram variable storage
;
;compile with gavrasm serial_assembly.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:serial_assembly.hex
;
;program to utilize adc mux
.device atmega 168
rjmp start
@BobBurns
BobBurns / helloInterrupt.asm
Created November 22, 2014 19:50
AVR Interrupts. Assembly version of Elliot Williams helloInterrupts.c
;Interrupt 0 Example
; Flashes LED0 at a fixed rate, interrupting whenever button is pressed
;
.device atmega 168
.def temp = r16
.def temp2 = r17
.org 0
;
;Interrupt Vector Table
jmp reset
@BobBurns
BobBurns / capSense.asm
Created November 27, 2014 00:02
example program using pin change interrupts from AVR Programming by Elliot Williams
;Capacitive sensor demo in avr assembly
;compile with gavrasm capSense.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.usbmodem1411 -b 19200 -U flash:w:capSense.hex
;
;
;what I learned from this program:
; always save the status reg when using interrupts
; and use the right jump vector for interrupt calls
; and keep track of registers used in subroutines
;