diff --git a/.gitignore b/.gitignore index 5271fcdc..cc3369af 100644 --- a/.gitignore +++ b/.gitignore @@ -36,12 +36,7 @@ # extras folder ################################################################ !/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra -!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/**/ -!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/**/*.md -!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/**/*.pdf -!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/**/*.svg -!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/**/*.png -!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/**/*.jpg +!/[A-Z]*[A-Z]-[A-Z]*[A-Z]/extra/** # just in case ################################################################# !.gitignore diff --git a/ASM-GUENTHER/extra/ASM-Programme/Beispiele/440hz.asm b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/440hz.asm new file mode 100644 index 00000000..9e4f20f5 --- /dev/null +++ b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/440hz.asm @@ -0,0 +1,190 @@ +/*********************************** +* * +* Was tut das Programm * +* * +* Autor: André Grimm * +* erstellt am: * +* Version 0.1 * +* * +***********************************/ + +.nolist +.include "m8515def.inc" +.list + +/********************************************* +* * +* Hardwarebeschreibung: * +* * +* STK500 -> * +* * +*********************************************/ + +.def work = R16 + +.equ Pieper=0 +.equ pinToToggle= 1 +.equ timeToWait= 277 +/***************** +* * +* Macros * +* * +*****************/ +;Berechnung Basistakt 1MHZ -> 100k HZ --> 1 Mio pro Sekunden +;Takt dauert 1/(1 Mio) Sekunden +; 1 / 440 +;Wechsel alle 440 * 1 / 1 Mio Sekunden = 440*10^-6 +; +////////////////////////////////////////////////////////////// +// +// Funktions- und Parameterbeschreibung +// +////////////////////////////////////////////////////////////// +.macro name +.endm + +/*************************** +* * +* Interrupt Vektor Tabelle * +* * +***************************/ +.org 0x0000 +rjmp start +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti + + +/********************* +* * +* Interrupt Handler * +* * +*********************/ + +////////////////////////////////////// +// +// Funktionsbeschreibung +// +////////////////////////////////////// +intName: +reti + + +/******************************** +* * +* Initialisierung * +* * +********************************/ +start: +;init Stack +ldi work, LOW(RAMEND) +out SPL, work +ldi work, HIGH(RAMEND) +out SPH, work + +;init registers +ldi R16, 0xFF ; de facto work +out DDRA, R16 ; alle pins am port A sind Ausgänge + +;init TIMER + + +/**************** +* * +* Hauptprogramm * +* * +****************/ +;CPU Takt 200kHz + +main: +rcall warte +rcall togglePin +rjmp main + + +/*ldi R18, 100 +outerloop: + ldi R17, 248 + loop: + nop ; 1 Takt + dec R17 ; 1 Takt + ;wiederholen solange R17 nicht null + BRNE loop ; 1 if condition is false, 2 if condition is true + ;2 Takte + dec R18 ; 1 Takt + ;wiederholen solange R17 nicht null + BRNE loop2 +*/ + + +;warte eine halbe Sekunde + + + + + +/***************** +* * +* Unterprogramme * +* * +*****************/ + + +////////////////////////////////////////////////////////////// +// +// schaltet Pin Um + +// Pin steht in Konstante pinToToggle +// +////////////////////////////////////////////////////////////// +togglePin: + push R15 + in R15, SREG + push R18 + + ldi R18, pinToToggle + + in work, PORTA + eor work, R18 + out PORTA, work + + pop R18 + out SREG, R15 + pop R15 +ret + +warte: +push R15 +in R15, SREG +push R24 +push R25 + +ldi R24, LOW(timeToWait) +ldi R25, HIGH(timeToWait) + + markeWarteloop: + sbiw R24, 1 + brne markeWarteloop + +pop R25 +pop R24 +out SREG, R15 +pop R15 +ret + + + + diff --git a/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Interrupt_0_1.asm b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Interrupt_0_1.asm new file mode 100644 index 00000000..c4acc965 --- /dev/null +++ b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Interrupt_0_1.asm @@ -0,0 +1,136 @@ +/*********************************** +* * +* Was tut das Programm * +* * +* Autor: Maximilian Kerst * +* G190367PI * +* erstellt am: * +* * +***********************************/ + +.nolist +.include "m8515def.inc" +.list + +/********************************************* +* * +* Hardwarebeschreibung: * +* * +* STK500 -> * +* * +*********************************************/ + +.def work = R16 +.def status = R15 + +/***************** +* * +* Macros * +* * +*****************/ + +////////////////////////////////////////////////////////////// +// +// Funktions- und Parameterbeschreibung +// +////////////////////////////////////////////////////////////// +.macro name +.endm + +/*************************** +* * +* Interrupt Vektor Tabelle * +* * +***************************/ +.org 0x0000 +rjmp start +rjmp t1h ; 2 External Interrupt 0 +rjmp t2h ; 3 External Interrupt 1 +reti ; 4 Timer1 Cature Event +reti ; 5 Timer1 Compare Match A +reti ; 6 Timer1 Compare Match B +reti ; 7 Timer1 Overflow +reti ; 8 Timer0 Overflow +reti ; 9 Serial Transfer Complete +reti ; 10 +reti ; 11 +reti ; 12 +reti ; 13 +reti ; 14 External Interrupt 2 +reti ; 15 Timer0 Compare Match +reti ; 16 +reti ; 17 + + +/********************* +* * +* Interrupt Handler * +* * +*********************/ + +////////////////////////////////////// +// +// Funktionsbeschreibung +// +////////////////////////////////////// +t1h: + +in status, SREG +in work, PORTB +ldi R17, 0b00000001 +eor work, R17 +out PORTB, work +out SREG, status +reti + +t2h: + +in status, SREG +in work, PORTB +ldi R17, 0b00000010 +eor work, R17 +out PORTB, work +out SREG, status +reti + + +/******************************** +* * +* Initialisierung * +* * +********************************/ +start: +;init Stack +ldi work, LOW(RAMEND) +out SPL, work +ldi work, HIGH(RAMEND) +out SPH, work + +;init registers + +ldi work, 0xFF +out DDRB, work + +ldi work, 0b11000010 +out PORTB, work + +ldi work, 0b00001100 +out PORTD, work + +ldi work, 0b11000000 +out gicr, work + +ldi work, 0x0F +out mcucr, work + +SEI + + +/**************** +* * +* Hauptprogramm * +* * +****************/ +main: + +rjmp main diff --git a/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Programmspeicher_Interrupt_MelodieMitTaste.asm b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Programmspeicher_Interrupt_MelodieMitTaste.asm new file mode 100644 index 00000000..d08ae4bf --- /dev/null +++ b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Programmspeicher_Interrupt_MelodieMitTaste.asm @@ -0,0 +1,234 @@ +/*********************************** +* * +* Auf Knopfdruck 1 mal "Alle meine * +* Entchen" spielen * +* "Siehe Video!" ~J. Süße * +* Autor: André Grimm * +* erstellt am: 24.02.2015 * +* * +***********************************/ + +.nolist +.include "m8515def.inc" +.list + +.def work = R16 +.def ton = R17 +.def dauer = R18 +.def count = R19 +.def adressh = R20 +.def adressl = R21 +.def flags = R22 + +.equ csek = 9999 +.equ schluss = 0 +.equ voegel = 0 + + +/********************************************* +* * +* STK500 -> interner Takt vom STK 8 MHz * +* * +* Pin B0 -> Piepser * +* * +*********************************************/ + +/***************** +* * +* Macros * +* * +*****************/ + +///////////////////////////////////////////////////////////////// +// +// sichert den Wert des Registers work und des Statusregisters +// auf dem Stack +// Parameter: keine +// +///////////////////////////////////////////////////////////////// +.macro saveState + push work + in work, SREG + push work +.endmacro + +///////////////////////////////////////////////////////////////// +// +// lädt den Wert des Registers work und des Statusregisters +// vom Stack +// Parameter: keine +// +///////////////////////////////////////////////////////////////// +.macro loadState + pop work + out SREG, work + pop work +.endmacro + +/******************************** +* * +* IV-Tabelle * +* * +********************************/ +.org 0x0000 +rjmp start +reti +reti +reti +rjmp timer1CM_ISR +reti +reti +reti +reti +reti +reti +reti +reti +rjmp ExtInt2 +reti +reti +reti + +timer1CM_ISR: + saveState + + inc count + + loadState +reti + +ExtInt2: + saveState + + ORI flags, 0b00000001 + + loadState +reti + +/******************************** +* * +* Los geht's * +* * +********************************/ +start: +;init Stack +ldi work, LOW(RAMEND) +out SPL, work +ldi work, HIGH(RAMEND) +out SPH, work + +;init PORTB +ser work ;schreibt FF in Register R16 +out DDRB, work ;alle Pins an PortB Ausgänge +out PORTB, work ;alle Pins auf high -> STK-LEDs aus + +;init TIMER0 +clr work +out TCNT0, work +out TCCR0, work ;Timer aus + +;init Timer1 +out TCNT1H, work +out TCNT1L, work + +ldi work, 1< CTIEF + +loopWarte: + cp count, dauer + breq endWarte + rjmp loopWarte + +endWarte: + ldi work, schluss + out TCCR1B, work ;Timer1 anhalten + ldi count, 0 + loadState +ret +/************ +* * +* Daten * +* * +************/ +data: +.db 118,60,95,20,79,40,59,40,71,40,59,20,71,20,79,80,89,60,79,20,95,40,118,40,105,80,118,40,0 + diff --git a/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Warteschleife.asm b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Warteschleife.asm new file mode 100644 index 00000000..ddf4a27e --- /dev/null +++ b/ASM-GUENTHER/extra/ASM-Programme/Beispiele/Warteschleife.asm @@ -0,0 +1,140 @@ +/*********************************** +* * +* Was tut das Programm * +* * +* Autor: André Grimm / Süße * +* erstellt am: * +* Version 0.1 * +* * +***********************************/ + +.nolist +.include "m8515def.inc" +.list + +/********************************************* +* * +* Hardwarebeschreibung: * +* * +* STK500 -> * +* * +*********************************************/ + +.def work = R16 + +.equ Taster0 = 0 + +/***************** +* * +* Macros * +* * +*****************/ + +////////////////////////////////////////////////////////////// +// +// Funktions- und Parameterbeschreibung +// +////////////////////////////////////////////////////////////// +;.macro name +;.endm +.equ count = 24996 +/*************************** +* * +* Interrupt Vektor Tabelle * +* * +***************************/ +.org 0x0000 +rjmp start +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti +reti + +/******************************** +* * +* Initialisierung * +* * +********************************/ +start: +;init Stack +ldi work, LOW(RAMEND) +out SPL, work +ldi work, HIGH(RAMEND) +out SPH, work + +;init registers +ldi R16, 0xFF ; de facto work +out DDRA, R16 ; alle pins am port A sind Ausgänge + +;init TIMER + + +/**************** +* * +* Hauptprogramm * +* * +****************/ +;CPU Takt 200kHz + +main: + +sbi PORTA, 0 + +;warte eine halbe Sekunde +;nachschauen, wie viele Takte Kommando braucht +;25k Takte sind abzuarbeiten + + +rcall warte + +/*ldi R18, 100 +outerloop: + ldi R17, 248 + loop: + nop ; 1 Takt + dec R17 ; 1 Takt + ;wiederholen solange R17 nicht null + BRNE loop ; 1 if condition is false, 2 if condition is true + ;2 Takte + dec R18 ; 1 Takt + ;wiederholen solange R17 nicht null + BRNE loop2 +*/ + +cbi PORTA,0 +rjmp main + +warte: +;Register, die geändert werden, müssen noch gesichert werden +push R15 ;optional, denn R15 wird nicht benutzt; als Best-Practice +in R15, SREG +push R24 +push R25 +ldi R24, LOW(count) +ldi R25, HIGH(count) + + markeWarteloop: + sbiw R24, 1 + brne markeWarteloop + +pop R25 +pop R24 +out SREG, R15 +pop R15 +ret +;warte eine halbe Sekunde + + + diff --git a/ASM-GUENTHER/extra/ASM-Programme/README.md b/ASM-GUENTHER/extra/ASM-Programme/README.md new file mode 100644 index 00000000..f194ef1c --- /dev/null +++ b/ASM-GUENTHER/extra/ASM-Programme/README.md @@ -0,0 +1,4 @@ +- Alle Angaben ohne Gewähr! Nicht alle Dateien sind auf Lauffähigkeit überprüft. +- Die Dateien sind mehr als Grundbaugerüst zu sehen. +- Templatesammlung -> immer kommentiert +- Aber bessere Anwendung / vollständiger Code teilweise in Beispiele zu finden diff --git a/ASM-GUENTHER/extra/ASM-Programme/Templatesammlung/Interrupt_2_1.asm b/ASM-GUENTHER/extra/ASM-Programme/Templatesammlung/Interrupt_2_1.asm new file mode 100644 index 00000000..372ba672 --- /dev/null +++ b/ASM-GUENTHER/extra/ASM-Programme/Templatesammlung/Interrupt_2_1.asm @@ -0,0 +1,143 @@ +/************************************* +* * +* Interrupt Template * +* * +* Autor: Grimm / Schäfer * +* erstellt am: * +* Version 0.1 * +* * +*************************************/ + +.nolist +.include "m8515def.inc" +.list + +/********************************************* +* * +* Hardwarebeschreibung: * +* * +* PIN E0 -> Taster -> Int2 * +* PIN E1 -> LED * +* * +*********************************************/ + +.def status = R15 +.def work = R16 +.def mask = R17 ;CHANGE ME + + + +/*************************** +* * +* Interrupt Vektor Tabelle * +* * +***************************/ +.org 0x0000 +rjmp start ;1 External Pin, Power-on Reset, Brown-out Reset and Watchdog Reset +reti ;2 External Interrupt Request 0 +reti ;3 External Interrupt Request 1 +reti ;4 Timer/Counter1 Capture Event +reti ;5 Timer/Counter1 Compare Match A +reti ;6 Timer/Counter1 Compare Match B +reti ;7 Timer/Counter1 Overflow +reti ;8 Timer/Counter0 Overflow +reti ;9 Serial Transfer Complete +reti ;10 +reti ;11 +reti ;12 +reti ;13 +reti ;14 External Interrupt Request 2 +reti ;15 Timer/Counter0 Compare Match +reti ;16 +reti ;17 + + +/********************* +* * +* Interrupt Handler * +* * +*********************/ + +////////////////////////////////////// +// +// toggelt LED +// +////////////////////////////////////// +interrupt: ;CHANGE ME + //Statusregister sichern + IN status, SREG + + + //Statusregister wiederherstellen + OUT SREG, status +reti + + +/******************************** +* * +* Initialisierung * +* * +********************************/ +start: +;stack +LDI work, HIGH(RAMEND) +OUT SPH, work +LDI work, LOW(RAMEND) +OUT SPL, work + +;init registers +LDI work, 2 ;Ausgabe DDR 1 setzen +OUT DDRE, work +LDI work, 3 ;bei Eingabe Pull Up setzen, Ausgabe LED anmachen +OUT PORTE, work + +;init int2 + +/*Aufbau GCICR,x irrelevant +INT1 INT0 INT2 x x x x +Einerstelle: Interrupt-Nummer +Zehnerstelle: Identifier*/ + +in work, GICR ;durch GICR wird der Interrupt generell aktiviert +ldi mask, 0b00100000 ; 0b1 -> Interrupt 1; 0b01 -> Interrupt 0; 0b001 -> Interrupt 2 +or work, mask +out GICR, work + +/* +;Aufbau MCUCR x irrelevant +x x x x ISC11 ISC10 ISC01 ISC00 +Einerstelle: Interrupt-Nummer +Zehnerstelle: Identifier +EMUCR nur niedrigstes Bit relvant +Für Interrupt 1: +ISC11 ISC01 +0 0 low level interrupt +0 1 zwei-flankengesteuerter Interrupt +1 0 fallende Flanke +1 1 steigende Flanke +Interrupt 2 nur flanken-aktiv 0 --> fallend +ISC2 +*/ + +in work, EMCUCR ;EMCUCR bei Int2, MCUCR bei Int0+1 s. PP Folie 37+38 +ldi mask, 0b11111110 +out EMCUCR, work + +; Externer Interrupt 1 +;in work, MCUCR +;in mask, (1< LEDs * +* * +*********************************************/ + +.def work = R16 + +.equ Taster0 = 0 +.equ count = 256-240 ; Tatsächlich wird diese Berechnung durchgeführt = 16 + +/*************************** +* * +* Interrupt Vektor Tabelle * +* * +***************************/ +.org 0x0000 +rjmp start +reti +reti +reti +reti +reti +reti +rjmp timer0OFHandle +reti +reti +reti +reti +reti +reti +reti +reti +reti + + +/********************* +* * +* Interrupt Handler * +* * +*********************/ + +////////////////////////////////////// +// +// Funktionsbeschreibung +// +////////////////////////////////////// +; Hier ändern +timer0OFHandle: + in work, PINB ;Status von PINB lesen + inc work ; Work +1 + cpi work, 16 ; compare with immediate: 16 + breq nullen ; wenn equal -> jump nullen +back: + out PORTB, work ; Ausgabe +reti ; Ende des Interrupt + +nullen: ; Work auf 0 + ldi work, 0 + rjmp back + +/******************************** +* * +* Initialisierung * +* * +********************************/ +start: +;init Stack +ldi work, LOW(RAMEND) +out SPL, work +ldi work, HIGH(RAMEND) +out SPH, work + +;init registers +ldi work, 255 +out DDRB, work //alle Ports sind Ausgänge + +;init TIMER +;239 Timer-Takte zählen +ldi work, count ; count ist 16 -> von 16 bis 255 zählen +out TCNT0, work ; TCNT0 ist Register mit Start-Wert des Timers + +ldi work, 1<