.include "c:\avrtools\appnotes\8515def.inc" .device AT90S8515 ; specifies to the assembler which chip we are using .def pgmem =r0 .def status =r1 ;0x000000 ::: lower mem (0) / upper mem (1) ::: erase (0) / write (1) .def trigger =r2 ;trigger level .def save =r3 ;used to save SREG .def triggerlast =r4 ;stores last trigger value to erase marker .def buttonpress =r5 ;button currently pressed down .def timebase =r6 ;from zero to 11 .def voltbase =r7 ;from zero to 5, covers 200mV, 500mV, 1V, 2V, 5V, 10V .def debstate =r8 ;state variable for debounce .def lastbutton =r9 ;last button pressed .def acknowledged =r10 ;used for communication between debounce interrupt and analyze user input .def button =r11 ;button pressed as seen by analyze user input procedure .def gridselect =r12 ;grid on or off .def triggermode =r13 ;trigger mode 0 - 3 (internal, internal capture, external, external capture) .def zeroed =r14 ;keeps memory to zero out memory if trigger changes to hold .def upload =r15 .def Temp =r16 ;temporary register .def Temp1 =r17 ;another temporary register .def addrl =r18 ;temporary address register .def state =r19 ;state for trigger .def addrh =r20 ;temporary address register .def acq =r21 .def cnt =r22 ;generic counter .def addrstarth =r24 ;temporary address register .def addrstartl =r25 ;temporary address register .def data =r26 ;used for misc. data .def send =r27 .def tempi =r28 ;temporary register for interrupt ;*******definitions for floating point math ;states for debounce .equ wait =1 .equ debounce =2 .equ acknowl =3 .equ depress =4 .equ memstart = 0x0060 ;start of memory .equ displength = 30 ;display length in 6 bit wide characters .equ datarecv = 10 ;number of bytes received .equ datasend = 4 ;number of bytes sent .include "macros.asm" ;*************************************MAIN PROGRAM********************************************* .cseg .org $0000 rjmp RESET ;reset entry vector reti ;external intrupt not used reti reti reti reti reti rjmp getinput ;used to scan buttons reti reti reti reti reti reti reti RESET: ldi Temp, low(RAMEND) out SPL, Temp ldi Temp, high(RAMEND) out SPH, Temp ldi temp, 0b00111111 ;initialize trigger mov trigger, temp ldi temp, 5 ;initialize time base mov timebase, temp mov voltbase, temp ;initialize voltage base ldi temp, 0xFF ;initialize grid select mov gridselect, temp ldi temp, 0 ;initialize trigger mode mov triggermode, temp ;initialize debouncing state machine ldi temp, wait mov debstate, temp ldi temp, 0x00 mov acknowledged, temp ldi temp, 0xFF mov buttonpress, temp mov lastbutton, temp mov button, temp ;DDRA is changed depending on read or write data to LCD ;set port B for LCD control and processor communication ldi temp, 0b10111111 out DDRB, temp clr temp out PORTB, temp ;port C for communication is two way, therefore changes clr temp ;set portD to all inputs for switches out DDRD, temp out PORTD, temp ;turn off pull ups ;set up timer 0 prescale to 1024 to inturrupt every 30 ms for I/O ldi temp, 0b00000010 out TIMSK, temp ldi temp, 0b00000101 out TCCR0, temp ldi temp, 156 out TCNT0, temp sei ;initialize LCD display graphics area starting at 0000h statusi 0x03 writei 0x00 statusi 0x03 writei 0x00 statusi 0x03 commandi 0x42 statusi 0x03 writei 0x28 statusi 0x03 writei 0x00 statusi 0x03 commandi 0x43 ;initialize LCD text area starting at 1400h statusi 0x03 writei 0x00 statusi 0x03 writei 0x14 statusi 0x03 commandi 0x40 statusi 0x03 writei 0x28 statusi 0x03 writei 0x00 statusi 0x03 commandi 0x41 ;set mode to "or" statusi 0x03 commandi 0x80 ;set display mode statusi 0x03 commandi 0x9C rcall clrallmem pgloop: delay: addi16 addrh, addrl, 1 ;delay to reduce flicker (increase intensity) cpi16 addrh, addrl, 0x7FFF brne delay rcall compinput ;compute user input rcall getdata ;get data from second processor ;the previous and current voltage data are stored so the previous waveform can be erased and ;immediately followed by a write of the next waveform ;delete old display (upper memory) ldi temp, 0b00000010 mov status, temp rcall memorydump ;write new display (lower memory) ldi temp, 0b00000001 mov status, temp rcall memorydump rcall copymemory ;updates everything on display rcall displayupdate rjmp pgloop ;*******************************clear all memory*************************************** ;clear all memory in micro-controller and display clrallmem: ;set the address pointer to the beginning of memory statusi 0x03 writei 0x00 statusi 0x03 writei 0x00 statusi 0x03 commandi 0x24 ;Zero out counter ldi addrh,0 ldi addrl,0 ;set up autowrite statusi 0x03 commandi 0xB0 clrmemloop: ;inc counter addi16 addrh, addrl, 0x0001 ;write zero to memory statusi 0x08 writei 0x00 ;check loop status cpi16 addrh, addrl, 0x1680 brne clrmemloop ;return LCD controller to normal mode statusi 0x08 commandi 0xB2 ret ;*******************************Display Data************************************ ;dump waveform from memory to LCD display memorydump: sbrc status, 1 ;determine upper or lower memory status rjmp memupper ldi R30, low(memstart) ldi R31, high(memstart) rjmp memlower memupper: ldi R30, low(memstart + 6 * displength + 1) ldi R31, high(memstart + 6 * displength + 1) memlower: ldi addrstarth, high(0x13D8) ldi addrstartl, low(0x13D8) clr data smemaddr: ;outer loop goes from 0x13D8 to (0x13D8 + displength) cpi16 addrstarth, addrstartl, (0x13D8 + displength) breq resmemaddr mov addrh, addrstarth ;set addrh and addrl mov addrl, addrstartl ldi data,5 ;set data smemloc: cpi data,0 ;middle loop goes from data=5 to data=0 brlt resmemloc ld cnt, Z+ lsr cnt ;shift to display top seven bits ;jump table resolving rjmp nothing resmemloc: rjmp memloc resmemaddr: rjmp memaddr nothing: smemmult: cpi cnt,0 ;subtract 40 from addr cnt times breq memmult subi16 addrh, addrl, 40 dec cnt rjmp smemmult memmult: ;set memory pointer statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 statusi 0x03 ldi send, 0b11111000 ;determine write or erase status sbrs status, 0 ldi send, 0b11110000 or send, data command send ;display bit dec data mov addrh, addrstarth mov addrl, addrstartl rjmp smemloc memloc: addi16 addrstarth, addrstartl, 1 rjmp smemaddr memaddr: ret ;**********************************Draw Grid*********************************** ;draw the grid drawgrid: ;set address pointer at middle of screen statusi 0x03 writei 0x00 statusi 0x03 writei 0x0A statusi 0x03 commandi 0x24 ldi data, 0xFF rcall drawhorizline ;determine grid select status mov temp, gridselect cpi temp, 0xFF breq grid rjmp nogrid grid: ;set address pointer statusi 0x03 writei 0x70 statusi 0x03 writei 0x03 statusi 0x03 commandi 0x24 ldi data, 0x55 rcall drawhorizline ;set address pointer statusi 0x03 writei 0xB8 statusi 0x03 writei 0x06 statusi 0x03 commandi 0x24 rcall drawhorizline ;set address pointer statusi 0x03 writei 0x48 statusi 0x03 writei 0x0D statusi 0x03 commandi 0x24 rcall drawhorizline ;set address pointer statusi 0x03 writei 0x90 statusi 0x03 writei 0x10 statusi 0x03 commandi 0x24 rcall drawhorizline ;Draw vertical lines ldi addrstarth, high(0x07) ldi addrstartl, low(0x07) clr data drawlines: inc data mov addrh, addrstarth mov addrl, addrstartl clr cnt drawline: inc cnt ;set address pointer statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 statusi 0x03 ;and write data commandi 0b11111101 addi16 addrh, addrl, 80 cpi cnt, 64 breq drawlinedone rjmp drawline drawlinedone: addi16 addrstarth, addrstartl, 7 cpi data, 4 breq drawlinesdone rjmp drawlines drawlinesdone: ldi addrstarth, high(0x03) ldi addrstartl, low(0x03) clr data drawlines1: inc data mov addrh, addrstarth mov addrl, addrstartl clr cnt drawline1: inc cnt ;set address pointer statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 statusi 0x03 ;and write data commandi 0b11111010 addi16 addrh, addrl, 80 cpi cnt, 64 breq drawlinedone1 rjmp drawline1 drawlinedone1: addi16 addrstarth, addrstartl, 7 cpi data, 4 breq drawlinesdone1 rjmp drawlines1 drawlinesdone1: nogrid: ret ;Draw a horizontal line drawhorizline: ;set up autowrite statusi 0x03 commandi 0xB0 ldi addrl, 0 drawgridloop: ;write zero to memory statusi 0x08 write data ;check loop status inc addrl cpi addrl, displength brne drawgridloop ;return LCD controller to normal mode statusi 0x08 commandi 0xB2 ret ;********Call all display related procedures************ displayupdate: rcall disptrigger rcall drawgrid rcall writelabels rcall writedata rcall triggermode rcall disptimebase rcall dispvoltagebase ret ;*************************copy memory************************** ;copy lower half of memory to upper half for waveform buffer copymemory: ldi R30, low(memstart) ldi R31, high(memstart) cpymemloop: ld temp, Z addi16 R31, R30, (displength * 6 + 1) st Z+, temp subi16 R31, R30, (displength * 6 + 1) cpi16 R31, R30, (memstart + displength * 6) brne cpymemloop ret ;************************Display trigger level********************** disptrigger: ldi addrh, high(0x13D8) ldi addrl, low(0x13D8) clr data ;erase old trigger mov cnt, triggerlast ldi temp, 2 add cnt, temp ;set cnt to the top of the pointer ;resolve the trigger value into screen addressable units edspltrigmult: subi16 addrh, addrl, 40 dec cnt cpi cnt, 0 brne edspltrigmult clr cnt ;erase last trigger by writing zeros over it ;initialize data, top 2 bits don't count because of 6 bit addressing mode ldi data, 0b11000000 edspltloop: ;set address pointer statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;write data statusi 0x03 write data statusi 0x03 commandi 0xC4 addi16 addrh, addrl, 40 inc cnt cpi cnt, 5 breq edspltend rjmp edspltloop edspltend: ;display new trigger ldi addrh, high(0x13D8) ldi addrl, low(0x13D8) mov temp, trigger mov triggerlast, temp mov cnt, temp ldi temp, 2 add cnt, temp ;set cnt to the top of the trigger pointer on screen ;resolve the value into screen addressable units dspltrigmult: subi16 addrh, addrl, 40 dec cnt cpi cnt, 0 brne dspltrigmult clr cnt ;initialize data, top 2 bits don't count because of 6 bit addressing mode ldi data, 0b11000000 dspltloop: ;the on screen triangle is drawn by shifting in a 1 from the left on each write, then ;shifting shifting in a zero from the right ;set data appropriately cpi cnt, 3 brsh dspltsl sec ;set carry flag ror data ;and shift right rjmp dspltsr dspltsl: clc ;clear carry flag rol data ;and shift left dspltsr: ;set address pointer statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;write data statusi 0x03 write data statusi 0x03 commandi 0xC4 addi16 addrh, addrl, 40 inc cnt cpi cnt, 5 breq dspltend rjmp dspltloop dspltend: ret ;**********************GETDATA******************** ;send and receive data from other processor getdata: ;set port C for communication to begin receiving data clr temp out DDRC, temp clr temp out PORTC, temp ;check to see that sender is ready with data in temp, PINB ldi data, 0b01000000 and temp, data cpi temp, 0b01000000 brne exitgetdata rcall consolidate ;set Z ldi Zl, low(memstart) ldi Zh, high(memstart) ;get data from other chip getmore: ;do not affect other data on PINB, very important not to disturb LCD display in data, PINB ldi temp, 0b10000000 or temp, data out PORTB, temp ;must have this number of nops for master at 4Mhz and slave at 8Mhz ;need this time for slave to get data ready after clock edge nop nop nop nop nop nop nop nop nop nop nop nop nop ;get the data in data, PINC st Z+, data ;after waveform is received, set memory pointer to memstart + 420 to receive ;floating point data and avoid overwriting the waveform buffer cpi16 R31, R30, (memstart + displength * 6) brne gettingdata ldi R31, high(memstart + 420) ldi R30, low(memstart + 420) gettingdata: in data, PINB ldi temp, 0b01111111 and temp, data out PORTB, temp ;continue to get all data cpi16 R31, R30, (memstart + 420 + datarecv) brne getmore ;now start sending data to other processor sendingdata: ;Due to the way each processor communicates, when switching over from receive to send, there ;will be a short overlap where both processors will be sending data, but the robust ATMEL ;chips can handle this with their protection diodes clr cnt ser temp out DDRC, temp ;set portc for outputs ld data, Z+ ;put first data byte on portC out PORTC, data in data, PINB ;raise the inturrupt line for the second processor ldi temp, 0b10000000 or temp, data out PORTB, temp nop nop nop in data, PINB ldi temp, 0b01111111 and temp, data out PORTB, temp ;continue until all data is sent cpi16 R31, R30, (memstart + 420 + datarecv + datasend) brne sendingdata ;store voltage base after getting it ldi R31, high(memstart + 420 + 9) ldi R30, low(memstart + 420 + 9) ld voltbase, Z exitgetdata: ;rcall eraseupload ret ;currently not used due to strange bug eraseupload: ldi addrl, low(0x1676) ldi addrh, high(0x1676) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 clr data deletelabel1: inc data statusi 0x03 writei 0x00 statusi 0x03 commandi 0xC0 cpi data, 9 brne deletelabel1 ret ;consolidate all variables to be sent to memory consolidate: ldi R31, high(memstart + 420 + datarecv) ldi R30, low(memstart + 420 + datarecv) st Z+, trigger st Z+, timebase st Z+, triggermode ret ;************************GETINPUT**************************** ;on timer0 inturrupt get input from PORTD ;state machine debounces input getinput: in save, SREG in buttonpress, PIND mov tempi, debstate cpi tempi, wait breq wait3 cpi tempi, debounce breq debounce3 cpi tempi, acknowl breq acknowl3 cpi tempi, depress breq depress3 wait3: mov tempi, buttonpress cpi tempi, 0xFF breq debdone mov lastbutton, buttonpress ldi tempi, debounce mov debstate, tempi rjmp debdone debounce3: cp buttonpress, lastbutton brne debounce1 ldi tempi, acknowl mov debstate, tempi mov button, buttonpress rjmp debdone debounce1: ldi tempi, wait mov debstate, tempi rjmp debdone acknowl3:ldi tempi, 0xFF cp acknowledged, tempi brne debdone ser tempi mov button, tempi ldi tempi, depress mov debstate, tempi ldi tempi, 0x00 mov acknowledged, tempi rjmp debdone depress3: ldi tempi, 0xFF cp buttonpress, tempi brne debdone ldi tempi, wait mov debstate, tempi debdone: out SREG, save reti ;*******************Compute User Input*********************** ;after getting user input, do something with it compinput: clr temp mov zeroed, temp ;determine if debounce state machine gives us a useful input ldi temp, 0xFF cp button, temp breq nopress ;tell second processor to no longer upload data in temp, PINB andi temp, 0b11101111 out PORTB, temp ;tell debounce state machine that button pressed was acknowledged ldi temp, 0xFF mov acknowledged, temp ldi temp, 4 ;determine trigger changes sbrs button, 7 add trigger, temp sbrs button, 6 sub trigger, temp sbrs button, 5 inc timebase sbrs button, 4 dec timebase ;set grid status sbrc button, 3 rjmp nogridchange com gridselect rcall clrallmem nogridchange: ;set trigger mode sbrc button, 2 rjmp nohold ;toggle interrupt line every time trigger is changed rcall pulse ;check end conditions for value of triggermode inc triggermode mov temp, triggermode cpi temp, 4 brne trignochange ldi temp, 0 mov triggermode, temp trignochange: mov temp, triggermode cpi temp, 1 brne nohold ser temp mov zeroed, temp nohold: ;check end conditions for timebase mov temp, timebase cpi temp, 0xFF brne tbaseok clr temp mov timebase, temp tbaseok: mov temp, timebase cpi temp, 12 brne tbasehok ldi temp, 11 mov timebase, temp tbasehok: ;pulse to get new sample on hold mode mov temp, button cpi temp, 0b11111101 brne nobreak rcall pulse nobreak: ;upload data, but only allow on hold modes mov temp, triggermode cpi temp, 0 breq nocapture cpi temp, 2 breq nocapture ;capture mode mov temp, button cpi temp, 0b11111110 brne nocapture in temp, PINB ori temp, 0b00010000 out PORTB, temp ; rcall writeupload ;tell second processor to start uploading data rcall pulse nocapture: ;if nocapture, upload is reset at beginning of function nopress: ret writeupload: ldi addrl, low(0x164E) ldi addrh, high(0x164E) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ldi ZH, high(uploading * 2) ldi ZL, low(uploading * 2) ldi data, 9 rcall writepgmem ret pulse: ldi temp, 0b00100000 in temp1, PINB or temp, temp1 out portb, temp nop nop nop nop nop nop ldi temp, 0b11011111 and temp1, temp out portb, temp1 ret ;************************Write Labels************************************* ;Write waveform labels starting writelabels: ;set pointer to begin writing frequency label ldi R31, high(FREQ*2) ldi R30, low(FREQ*2) ldi addrl, low(0x141E) ldi addrh, high(0x141E) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ldi data, 10 ;write frequency label rcall writepgmem ;set pointer to begin writing Vp-p label ldi R31, high(Vpp*2) ldi R30, low(Vpp*2) ldi addrl, low(0x150E) ldi addrh, high(0x150E) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ldi data, 10 rcall writepgmem ;set pointer to begin writing period label ldi addrl, low(0x1496) ldi addrh, high(0x1496) ldi R30, low(period * 2) ldi R31, high(period * 2) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ldi data, 10 rcall writepgmem ret ;*******CONSTANTS********* ;constants used to write labels to screen FREQ: .db 0x00,0x26,0x52,0x45,0x51,0x00,0x08,0x28,0x5a,0x09 ;Freq (Hz) Vpp: .db 0x00,0x36,0x50,0x0d,0x50,0x00,0x08,0x36,0x09,0x00 ;Vp-p (V) Period: .db 0x00,0x30,0x45,0x52,0x49,0x4F,0x44,0x08,0x33,0x09 ;Period (S) ;**********************WRITEDATA************************ ;write floating point data from memory to screen, starting at position 420 writedata: ;write voltage to screen ldi R30, low(memstart + 420) ldi R31, high(memstart + 420) ;set memory pointer for LCD ldi addrl, low(0x1538) ldi addrh, high(0x1538) ;set memory pointer to floating point info for voltage ldi R30, low(memstart + 420) ldi R31, high(memstart + 420) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 rcall datatoscreen ;write frequency to screen ldi R30, low(memstart + 423) ldi R31, high(memstart + 423) ldi addrl, low(0x1448) ldi addrh, high(0x1448) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 rcall datatoscreen ;write the period to screen ldi R30, low(memstart + 426) ldi R31, high(memstart + 426) ldi addrl, low(0x14C0) ldi addrh, high(0x14C0) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 rcall datatoscreen ret ;convert compressed data format to readable floating point format datatoscreen: ;write data to screen ld data, Z swap data rcall writerightdigit ldi data, 0x0E rcall writedatascreen ld data, Z+ rcall writerightdigit ld data, Z swap data rcall writerightdigit ld data, Z+ rcall writerightdigit ;write period to screen ldi data, 0x45 rcall writedatascreen ;write exponent ld cnt, Z+ sbrs cnt, 7 rjmp posexp neg cnt ldi data, 0x0D ;write negative sign rcall writedatascreen mov data, cnt rcall writerightdigit rjmp negexp posexp: ldi data, 0x0B rcall writedatascreen mov data, cnt rcall writerightdigit negexp: ret ;write right digit of byte to screen writerightdigit: andi data, 0b00001111 ori data, 0b00010000 statusi 0x03 write data statusi 0x03 commandi 0xC0 ret ;write byte to screen writedatascreen: statusi 0x03 write data statusi 0x03 commandi 0xC0 ret ;*********************display time base************************* ;display the time base disptimebase: ;set pointer to begin writing timebase label ldi addrl, low(0x1587) ldi addrh, high(0x1587) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;write time/Div ldi R30, low(TimeDiv * 2) ldi R31, high(TimeDiv * 2) clr cnt ldi data, 8 rcall writepgmem ;on next line, write actual value for Time/Div ldi R30, low(Time * 2) ldi R31, high(Time * 2) ;set pointer to next line clr temp add16 R31, R30, temp, timebase addi16 addrh, addrl, 40 statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;translate from compressed timebase format to readable format clr cnt lpm ldi temp, 0b11110000 and temp, pgmem cpi temp, 0xA0 brne notpoint ldi data, 0x0E ser cnt notpoint: cpi temp, 0xB0 brne notspace ldi data, 0x00 ser cnt notspace: cpi cnt, 0xFF breq special mov data, pgmem swap data rcall writerightdigit rjmp notspecial special:rcall writedatascreen notspecial: mov data, pgmem rcall writerightdigit ldi data, 0x00 rcall writedatascreen mov temp, timebase cpi temp, 9 brsh nomsec ldi data, 0x4D rcall writedatascreen nomsec: ;write 's' ldi temp, 0x53 mov data, temp rcall writedatascreen ;write 'e' ldi temp, 0x45 mov data, temp rcall writedatascreen ;write 'c' ldi temp, 0x43 mov data, temp rcall writedatascreen ;write space clr temp mov data, temp rcall writedatascreen ret ;*****************display voltage base******************** ;display voltage base (200mV, 500mV, 1V, 2V, 5V, 10V) dispvoltagebase: ;set pointer to begin writing volt base label ldi addrl, low(0x15FF) ldi addrh, high(0x15FF) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;write time/Div ldi R30, low(VoltsDiv * 2) ldi R31, high(VoltsDiv * 2) ldi data, 9 rcall writepgmem ;go to next line addi16 addrh, addrl, 41 statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;get volt base ldi R30, low(Volt * 2) ldi R31, high(Volt * 2) mov data, voltbase ;multiply by 4 to resolve in program memory lsl data lsl data clr temp add16 R31, R30, temp, data ;add adjustment to program memory pointer ldi data, 4 ;set length to write rcall writepgmem ;write voltage/div value to screen mov temp, voltbase cpi temp, 2 ;in mV or V range? brsh nomVlabel ldi data, 0x4D rcall writedatascreen ldi data, 0x36 rcall writedatascreen rjmp mVlabel nomVlabel: ldi data, 0x00 rcall writedatascreen ldi data, 0x36 rcall writedatascreen mVlabel: ret ;*****************display trigger mode******************** ;display the current trigger mode triggermode: ;set LCD pointer to begin writing trigger label ldi addrl, low(0x1676) ldi addrh, high(0x1676) statusi 0x03 write addrl statusi 0x03 write addrh statusi 0x03 commandi 0x24 ;set memory pointer to label ldi R30, low(trig * 2) ldi R31, high(trig * 2) ldi data, 6 ;set length to write rcall writepgmem ldi R30, low(tmode * 2) ldi R31, high(tmode * 2) mov data, triggermode lsl data ;multiply by 4 to resolve memory location lsl data clr temp add16 R31, R30, temp, data ldi data, 4 ;set triggermode length rcall writepgmem ret ;*********************Write Program Memory**************************** ;write the next data number of characters from program memory, assumes Z is already set up writepgmem: clr cnt writepgmemloop: inc cnt lpm addi16 R31, R30, 1 statusi 0x03 write pgmem statusi 0x03 commandi 0xC0 cp cnt, data brne writepgmemloop ret ;******************Labels******************************* uploading: .db 0x35, 0x50, 0x4C, 0x4F, 0x41, 0x44 .db 0x49, 0x4E, 0x47 ;Uploading trig: .db 0x34, 0x52, 0x49, 0x47, 0x1A, 0x00 ;trig:_ tmode: .db 0x49, 0x4e, 0x54, 0x00 ;int_ .db 0x49, 0x4e, 0x54, 0x28 ;intH .db 0x45, 0x58, 0x54, 0x00 ;ext_ .db 0x45, 0x58, 0x54, 0x28 ;extH ;***********Constants for timebase********** time: .db 0xA1, 0xA2, 0xA5, 0xB1 ;.1, .2, .5, 1 .db 0xB2, 0xB5, 0x10, 0x20 ;2, 5, 10, 20 .db 0x50, 0xA1, 0xA2, 0xA5 ;50, .1, .2, .5 TimeDiv: .db 0x34, 0x49, 0x4D, 0x45, 0x0F, 0x24, 0x49, 0x36 ;Time/Div ;***********Constants for voltage base********** volt: .db 0x12, 0x10, 0x10, 0x00 .db 0x15, 0x10, 0x10, 0x00 .db 0x00, 0x00, 0x11, 0x00 .db 0x00, 0x00, 0x12, 0x00 .db 0x00, 0x00, 0x15, 0x00 .db 0x00, 0x11, 0x10, 0x00 VoltsDiv: .db 0x36, 0x4F, 0x4C, 0x54, 0x53, 0x0F, 0x24, 0x49, 0x36 ;Volts/Div