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 / SPI-hello_eeprom.asm
Created December 10, 2014 23:48
demo assembly program using 25LC256 EEPROM with SPI
;demo program to learn how the avr can talk to another device with SPI
;in this case the 25LC256 eeprom
;
;based on the example code in c from Elliot Williams AVR Programming
;this example writes a string to the eeprom and then read it into sram to be sent over USART
;
;compile with gavrasm SPI-hello_eeprom.asm
;flash with avrdude -c avrisp -p m168 -P /dev/tty.useyourmodem -b 19200 -U flash:w:SPI-hello_eeprom.hex
;
;there are a couple extra convenience routines to use later
@BobBurns
BobBurns / reactionTimer.asm
Created November 29, 2014 03:58
reaction timer program from AVR Programming
;
;reaction timer program from AVR programming
;button on PD2 // leds on PORTB
;
.equ UBBRvalue = 12
.equ UCSR0C = 0xc2 ;SRAM address of UCSR0C
.def temp = r16
.def count = r17
.def temp2 = r18
.def xL = r26 ;x reg used as global counter
@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
;
@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 / 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 / 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 / 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 / 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 / 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 / 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