Assembler: Temperatur Info für Heizung

Folienkondensator

Neues Mitglied
28. Mai 2012
89
0
0
Sprachen
  1. ANSI C
  2. Assembler
Hallo

Ich hab mal wider ein neues Projekt angefangen. Es geht darum eine Anzeige zu erstellen die den aktuellen Status meiner heizung anzeigt. Dazu werden zwei NTCs an dem warmwasserspeicher und dem ofen angebracht. Über ein LCD Display wird der aktuelle Status angezeigt (Wenn der Wasserspeicher warm genug ist -> Alles in Ordnung) ( Wenn der Wasserspeicher kalt ist und der Ofen heiß -> Aufheizvorgang) ( wenn der Ofen kalt ist und der Wasserspeicher auch -> Bitte nachlegen!)

Um die Temperaturen ermitteln zu können soll eine Spannung durch die NTCs geleitet werden und nach einem entsprechendem Spannungsteiler in den ADC eines Mega8 geschikt werden. Der ADC soll dann anhand der Spannung die entsprechnenden Textausgaben steuern.

Das Programm wäre soweit fertig. nur gibz ein kleines Problem mit den ADCs. Den ADC0 zu benutzen ist mir schon bei anderen Projekten gelungen. aber jetzt habe ich zwei verschidene Spannungswerte zu verarbeiten. und ich hab auch nach vielen Googlen keine Beispiele gefunden wie man explizit einzelne ADCs ausliest. :confused:
Könnte mir jemand auf die Sprünge helfen?
Gruß

Hier mal der bisherige Quelltext (Die ADCs funktionieren nicht wie sie sollen. die Textausgaben jedoch nach einer ADC Manipulation einwandfrei)
@ Oldmax. Ich bin mir sicher du bekommst wider einen Herzinfakt bei dem Durcheinander. Aber ich versuch immer noch mich zu bessern :D

Code:
.include "m8def.inc"
 
;Alias Namen erstellen
.def temp1 = r16
.def temp2 = r17
.def temp3 = r18
.def temp4 = r19
.def temp5 = r20
.def temp6 = r21


;Stack Initialisieren 
	ldi temp1, LOW(RAMEND)  
	out SPL, temp1
	ldi temp1, HIGH(RAMEND)  
	out SPH, temp1






;****************************************************

;Ausgänge definieren
	LDI		temp1,0b11111111
	Out		DDRD,temp1

;ADC Initialisieren	
	LDI		temp1,(1<<REFS0) | (1<<ADLAR)	;Kanal 0 Interne Refferenzspannung
	out		ADMUX, temp1
	LDI		temp1,(1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0)
	out		ADCSRA,temp1






;Display Initialisieren
	rcall	Display_ini


;Hauptmenü
;****************************************************
Menue:
	


rcall	LCD_löschen

;	LDI		temp2,0b00000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
;	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print




	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'W'
	rcall	Print
	LDI		Temp2, 'I'
	rcall	Print
	LDI		temp2, 'L'
	rcall	Print
	LDI		Temp2, 'L'
	rcall	Print
	LDI		temp2, 'K'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print

Loop:

Wait_1000:
	LDI		r22,20
Wait_1001:
	LDI		r23,255
Wait_1002:
	LDI		r24,255
Wait_1003:
	dec		r24
	brne	Wait_1003
	dec		r23
	brne	Wait_1002
	dec		r22
	brne	Wait_1001	


Start_ADC0:
	ldi		temp1,(0<<MUX3) | (0<<MUX2) | (0<<MUX1) | (0<<MUX0)		;ADC0 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC0:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc0
;ADC Einlesen
	in		temp5,ADCL
	in		temp5,ADCH




Start_ADC1:
	ldi		temp1,(0<<MUX3) | (0<<MUX2) | (0<<MUX1) | (1<<MUX0)		;ADC1 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC1:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc1
;ADC Einlesen
	in		temp6,ADCL
	in		temp6,ADCH


Puffer:							;Puffertemperatur abfragen
	CPI		temp5,10			;Vergleiche ADC0 Wert mit 100
	BRLO	Kessel				;Springe zu Kessel wenn Wert unter 100		
	rjmp	Allesio				;Springe zu Allesio wenn Wert über 100

Kessel:							;Kesseltemperatur abfragen
	CPI		temp6,10			;Vergleiche ADC1 Wert mit 100
	BRLO	Nachlegen			;Springe zu Nachlegen wenn Wert unter 100
	rjmp	Aufheizen			;Springe zu Aufheizen wenn Wert über 100


;****Nachlegen****
Nachlegen:
rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print


	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, 'B'
	rcall	Print
	LDI		temp2, 'I'
	rcall	Print
	LDI		Temp2, 'T'
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'E'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'C'
	rcall	Print
	LDI		temp2, 'H'
	rcall	Print
	LDI		Temp2, 'L'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, '!'
	rcall	Print
	rjmp	Loop


;****Aufheizen****
Aufheizen:
rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print

	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'U'
	rcall	Print
	LDI		temp2, 'F'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'I'
	rcall	Print
	LDI		temp2, 'Z'
	rcall	Print
	LDI		Temp2, 'E'
	rcall	Print
	LDI		temp2, 'N'
	rcall	Print
	rjmp	Loop

;****Alles iO***
Allesio:
rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print

	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, 'A'
	rcall	Print
	LDI		temp2, 'L'
	rcall	Print
	LDI		Temp2, 'L'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'S'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'I'
	rcall	Print
	LDI		temp2, 'N'
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'O'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'D'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'U'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	rjmp	Loop

;			Unterprogramme
;-----------------------------------------------------------------


; Display Installieren
;**************************************************

Display_ini:
	rcall	Waitms20
	ldi		temp3,3
Widerholung:
	LDI		temp2,0b00000011
	Out		portd,temp2
	rcall	send
	dec		temp3
	brne	Widerholung
	LDI		temp2,0b00000010
	OUT		Portd,temp2
	rcall	send
	LDI		temp2,0b00101000
	rcall	Send_Befehl
	LDI		temp2,0b00001100
	rcall	Send_Befehl
	LDI		temp2,0b00000100
	rcall	Send_Befehl

	ret


;LCD Löschen
;*************************************************

LCD_Löschen:
	ldi		temp2,0b00000001
	rcall	Send_Befehl
	ret



;Aufs LCD schreiben
;*************************************************

Print:
	Mov		temp3,temp2
	swap	temp2
	andi	temp2,0b00001111
	sbr		temp2,0b00010000
	out		PortD,temp2
	rcall	send
	andi	temp3,0b00001111
	sbr		temp3,0b00010000
	OUT		Portd,temp3
	rcall	Send
	ret

;Instruktionen ans LCD
;*************************************************

Send_Befehl:
	Mov		temp3,temp2
	swap	temp2
	andi	temp2,0b00001111
	out		PortD,temp2
	rcall	send
	andi	temp3,0b00001111
	OUT		Portd,temp3
	rcall	Send
	ret	


;Warteschleifen
;************************************************
Waitms5:
	LDI		temp1,50
Waitms5_1:
	LDI		temp2,255
Waitms5_2:
	dec		temp2
	brne	waitms5_2
	dec		temp1
	brne	Waitms5_1
	ret
	


Waitms20:
	LDI		temp1,200
Waitms20_1:
	LDI		temp2,255
Waitms20_2:
	dec		temp2
	brne	waitms20_2
	dec		temp1
	brne	Waitms20_1
	ret


;Sendefreigabe
;************************************************
Send:
	SBI		portd,5
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	CBI		portd,5
	rcall	waitms5
	ret
 
Antwort gefunden

Hi
Jetzt hab ich den fehler gefunden.
Anscheinend waren in dem register in dem die MUX Bits gesetzt werden noch ein paar andere Bits gesetzt. Ich lösche jetzt temp1 vor jedem beladen mit neuen Bits. jetzt klapts ;) (BLAU)

Zudem habe ich beim beschreiben des ADMUX nicht nur die Bits angesprochen die für den Wechsel in den anderen Kanal wichtig sind, sondern alle7. so ist es ausgeschlossen dass sich irgendwelche falsch gesetzten Bits durch das ganze Programm zihen. (ROT)

Code:
Start_ADC0:
[COLOR="#0000FF"]	clr		temp1[/COLOR]
	[COLOR="#FF0000"]ldi		temp1,0b01100000[/COLOR]		;ADC0 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC0:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc0
	;ADC Einlesen
	in		temp5,ADCL
	in		temp5,ADCH
	cbi		ADCSRA,ADSC



Start_ADC1:
[COLOR="#0000FF"]	clr		temp1[/COLOR]
	[COLOR="#FF0000"]ldi		temp1,0b01100001[/COLOR]	;ADC1 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC1:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc1
	;ADC Einlesen
	in		temp6,ADCL
	in		temp6,ADCH
	cbi		ADCSRA,ADSC

Puffer:							;Puffertemperatur abfragen
	CPI		temp5,100			;Vergleiche ADC0 Wert mit 100
	BRLO	Kessel				;Springe zu Kessel wenn Wert unter 100		
	rjmp	Allesio				;Springe zu Allesio wenn Wert über 100

Kessel:							;Kesseltemperatur abfragen
	CPI		temp6,100			;Vergleiche ADC1 Wert mit 100
	BRLO	Nachlegen			;Springe zu Nachlegen wenn Wert unter 100
	rjmp	Aufheizen			;Springe zu Aufheizen wenn Wert über 100
 
Hallo,
Anscheinend waren in dem register in dem die MUX Bits gesetzt werden noch ein paar andere Bits gesetzt. Ich lösche jetzt temp1 vor jedem beladen mit neuen Bits. jetzt klapts ;) (BLAU)

wenn du "ldi" (load immediately) verwendest, wird ein konstanter Wert direkt in das Register kopiert. Du musst das Register zuvor nicht initialisieren.

Bei deiner ersten Programmversion hattest du die interne Referenzspannung eingestellt. Nun hast du AVCC als Referenzspannung gewählt und zusätzlich ADLAR gesetzt (left adjust des Ergebnisses). Vielleicht liegt es daran, warum deine erste Programmversion nicht so funktionierte, wie du es eigentlich erwartet hattest.

Dirk:ciao:
 
Hallo Dirk

ADLAR und die Referenzspannung habe ich ganz oben bei der Initialisierung gesetzt. Und genau das ist warscheinlich ein Problem gewesen. da diese Sachen alle über temp1 geladen werden. Temp1 wird auch noch für andere Sachen benutzt und ich nehme mal an dass beim Laden in temp1 via (1<<xxx) nur die angesprochenen Bits verändert werden. und wenn zufällig das Bit von ADLAR aus der Warteschleife noch auf NULL Steht funktioniert der ADC nichtmehr so wie er soll.
Anders bei Binäreingabe. so spricht man alle Bits an und kan sich sicher sein das alles so ist wie mans will xD
Soweit meine Einschätzung.

Was meinst du mit:
wenn du "ldi" (load immediately) verwendest, wird ein konstanter Wert direkt in das Register kopiert. Du musst das Register zuvor nicht initialisieren.
Werden da nicht nur die angesprochenen Bits verändert?

Gruß
 
Was meinst du mit:
wenn du "ldi" (load immediately) verwendest, wird ein konstanter Wert direkt in das Register kopiert. Du musst das Register zuvor nicht initialisieren.
Werden da nicht nur die angesprochenen Bits verändert?

Gruß

Mit zum Beispiel
ldi temp1, (0<<MUX3) | (0<<MUX2) | (0<<MUX1) | (1<<MUX0)
kopierst du einen konstanten Wert in das Register temp1 (bei dir r16). Oben der rechte Ausduck ist 0x01 oder 1d oder 0b00000001. Diese Zahl wird in temp1 abgelegt (temp1 = 1), der Wert der zuvor in temp1 enthalten war geht verloren.

"ldi" hat nichts mit einer Bitsetzfunktion zu tun.

Du musst also nicht temp1 vorher löschen (clr), das ist unnötig!

Das einzigste was kritisch wäre, wenn du temp1 (r16) auch in einer Interrupt-Serviceroutine verwendest. Aber da möchte ich jetzt nicht näher drauf eingehen, sonst kommst du vielleicht durcheinander.

Dirk :ciao:
 
Hi
Super, jetzt weis ich das auch mal ;)
Ich kann also nicht ein Bit setzen und später das nächste Bit setzten. ich muss praktisch immer alle Bits setzen. Egal ob einzeln durch (1<<xxx) oder 0b00000001.

Dann ist ja klar dass es nicht funktionieren konnte. ich habe oben die Referenzsspannung und die Bitausrichtung gemacht, und später den Kanal ohne Bitausrichtung oder referenz ausgewählt. dann ist natürlich die Referenz und die Ausrichtung verloren gegangen :D

Gruß
 
...Ich kann also nicht ein Bit setzen und später das nächste Bit setzten. ich muss praktisch immer alle Bits setzen. Egal ob einzeln durch (1<<xxx) oder 0b00000001.
...
Nein, so stimmt das auch wieder nicht. Schau mal in das AVR-Instruction-Set.
Mit den verschiedenen Load-Befehlen (LDI, LDS, LD) wird ein Byte (aus einer Konstante/festen SRAM-Zelle/indizierten SRAM-Zelle) in das Zielregister geladen. So wie dieses Byte ist, also mit allen gesetzten/gelöschten bits.
Du kannst aber auch beliebige einzelne bits (mit Hilfe einer Maske) in einem Rechenregister setzen (SBR) bzw löschen(CBR).
Was Dich vielleicht noch mehr interessieren wird ist, daß dasselbe sogar mit einigen I/O-Registern möglich ist. Ohne daß dazu eine Interaktion mit den Rechenregistern nötig wird. Mit den Befehlen SBI bzw CBI. Allerdings geht das nur bei den ersten 32 I/O-Registern.

(INteressant in dem Zusammenhang sind übrigens auch die Befehle LAT, LAS, LAC und XCH. Leider ist hier die Dokumentation sehr spärlich, UND was noch seltsamer ist: bisher hab ich keinen AVR gesehen, der diese Befehle zu unterstützen scheint...)
 
Ähnliches Problem

Nachdem ich den Thread gelesen hatte habe ich auch lust dazu bekommen den ADC
mal auszuprobieren.
Hatte ihn bisher noch nicht genutzt.
jetzt habe ich aber das Problem das der ADC nur einmal nach dem neustart des Controllers
Arbeitet und sonst nicht.
wollte ein Poti auslesen und den aktuellen Potiwert einfach auf LED´s ausgeben.

hier das Programm.
Code:
 .include"m8def.inc"

 init:

 ;Stack einrichten
 ldi r16,high(ramend)
 out sph,r16
 ldi r16,low(ramend)
 out spl,r16
 
 ;ADC initialisieren
 ldi r16,0b01000000 ;reference AVCC,ADC0
 out ADMUX,r16
 ldi r16,0b10000111 ;enable ADC,prescaler /128
 out ADCSRA,r16

 ;Ausgaenge definieren
 ldi r16,255
 out ddrd,r16


 ;Hauptprogramm
 startADC:

 sbi ADCSRA,ADSC
 wartenADC0:
 sbic ADCSRA,ADSC
 rjmp wartenADC0

 in r17,adcl
 out portd,r17
 cbi ADCSRA,ADSC
 rjmp startADC
 
jetzt habe ich aber das Problem das der ADC nur einmal nach dem neustart des Controllers
Arbeitet und sonst nicht.
wollte ein Poti auslesen und den aktuellen Potiwert einfach auf LED´s ausgeben.

Hallo,

probiere einmal folgendes:

Du nutzt im Moment nur 8Bit. Setze das Bit ADLAR im Register ADMUX, damit ist das Ergebnis linksbündig in den beiden Ergebnisregistern ADCH:ADCL. Nun holst du dir das 8Bit-Ergebnis aus dem Register ADCH, anstelle aus ADCL.

Dirk :ciao:

Datasheet:
When an ADC conversion is complete, the result is found in these two registers.
When ADCL is read, the ADC Data Register is not updated until ADCH is read. Consequently, if
the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read
ADCH. Otherwise, ADCL must be read first, then ADCH.
 
Falls Dich interessiert, was das Problem war:
If the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH. Otherwise, ADCL must be read first, then ADCH, to ensure that the content of the Data Registers belongs to the same conversion. Once ADCL is read, ADC access to Data Registers is blocked. This means that if ADCL has been read, and a conversion completes before ADCH is read, neither register is updated and the result from the conversion is lost. When ADCH is read, ADC access to the ADCH and ADCL Registers is re-enabled
ADCH hast Du aber nie ausgelesen, folglich liefert der ADC keine Werte mehr an die register, um inkohärente Daten zu vermeiden.

Quelle: Datenblatt des Mega8
 
danke auch dir nochmal
hattees mir aber selbst schon das Datenblatt nochmal genauer durchgelesen ;)
hatte das erst nicht richtig verstanden:rolleyes:
 
Fortschritt

Hallo

So, nun hab ich das Programm soweit fertig und ausführlich getestet. funktioniert prima.
Die Warteschleifen sind momentan für 8000MHz ausgelegt. Da ein Uhrenquarz kleiner ist und die Geschwindigkeit bei dem Programm keine große Rolle spielt wird er durch diesen ersetzt. Und die Wartezeiten angeglichen.

Hier mal der Code:

Code:
;Fumktion
;
;
;                                   ____     ____
;                                  |    |___|    |
;                           Reset -|1          28|- C5	Frei
;                   Display    D0 -|2          27|- C4	Frei
;                   Display    D1 -|3          26|- C3	Frei
;                   Display    D2 -|4          25|- C2	ADC2   Fotosensor (20K Dunkel)
;                   Display    D3 -|5          24|- C1  ADC1   Thermosens. Kessel (NTC 4,7K)
;                   Display    D4 -|6          23|- C0  ADC0   Thermosens. Puffer (NTC 4,7K)
;                             VCC -|7          22|- GND
;                             GND -|8          21|- Aref
;                           XTAL1 -|9          20|- AVCC
;                           XTAL2 -|10         19|- SCK
;                   Display    D5 -|11         18|- MISO
;         Res. Für BG Licht    D6 -|12         17|- MOSI
;                              D7 -|13         16|- B2    Microtaster 1
;  		Summer für Warnton     B0 -|14         15|- B1    Warn LED
;                                  |_____________|
;
;



.include "m8def.inc"
 
;Alias Namen erstellen

.def temp1 = r16
.def temp2 = r17
.def temp3 = r18
.def temp4 = r19
.def temp5 = r20
.def temp6 = r21
.def temp7 = r22

;Stack Initialisieren 
	ldi temp1, LOW(RAMEND)  
	out SPL, temp1
	ldi temp1, HIGH(RAMEND)  
	out SPH, temp1


;Ausgänge definieren
	LDI		temp1,0b11111111
	Out		DDRD,temp1
	LDI		temp1,0b00000111
	Out		DDRB,temp1
	LDI		temp1,0b11111111
	Out		DDRD,temp1


;ADC Initialisieren	
	LDI		temp1, (1<<REFS0) | (1<<ADLAR)	;Kanal 0 Interne Refferenzspannung
	out		ADMUX, temp1
	LDI		temp1, (1<<ADEN) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0)
	out		ADCSRA,temp1


;Display Initialisieren
	rcall	Display_ini

;Begrüßung
;**************

	rcall	LCD_löschen

	LDI		temp2,0b00000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print




	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'W'
	rcall	Print
	LDI		Temp2, 'I'
	rcall	Print
	LDI		temp2, 'L'
	rcall	Print
	LDI		Temp2, 'L'
	rcall	Print
	LDI		temp2, 'K'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print

;******************Hauptschleife*************************************************************************
Loop:




Wait_1000:							;Wait_1000 ist für die Abtastrate der Temperaturen zuständig
	LDI		r22,200					;Und auch für den Abstand des Warntons
Wait_1001:
	LDI		r23,255
Wait_1002:
	LDI		r24,255
Wait_1003:
	dec		r24
	brne	Wait_1003
	dec		r23
	brne	Wait_1002
	dec		r22
	brne	Wait_1001








Start_ADC0:
	ldi		temp1,0b01100000		;ADC0 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC0:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc0
	;ADC Einlesen
	in		temp5,ADCL
	in		temp5,ADCH
	cbi		ADCSRA,ADSC



Start_ADC1:
	ldi		temp1,0b01100001	;ADC1 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC1:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc1
	;ADC Einlesen
	in		temp6,ADCL
	in		temp6,ADCH
	cbi		ADCSRA,ADSC


Puffer:								;Puffertemperatur abfragen
	CPI		temp5,120;=40°C			;Vergleiche ADC0 Wert mit 120
	BRLO	Kessel					;Springe zu Kessel wenn Wert unter 120
	CPI		temp5,153;=60°C			;Vergleiche ADC0 Wert mit 153
	BRLO	Kessel2					;Springe zu Kessel2 wenn Wert unter 153
	rjmp	Allesio					;Springe zu Allesio wenn Wert über 153

Kessel:								;Kesseltemperatur abfragen
	CPI		temp6,153;=60°C			;Vergleiche ADC1 Wert mit 153
	BRLO	Nachlegen				;Springe zu Nachlegen wenn Wert unter 153
	rjmp	Aufheizen				;Springe zu Aufheizen wenn Wert über 153

Kessel2:							;Kesseltemperatur2 abfragen
	CPI		temp6,253;=60°C			;Vergleiche ADC1 Wert mit 153
	BRLO	Niedrig					;Springe zu Niedrig wenn Wert unter 153
	rjmp	Aufheizen				;Springe zu Aufheizen wenn Wert über 153
Niedrig:
	rjmp	Niedrig1				;Weiter Sprung zu Niedrig1	
	










;****Nachlegen****
Nachlegen:
	SBI		portb,1				;Warn LED ein schalten
	rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'h'
	rcall	Print
	LDI		temp2, 'e'
	rcall	Print
	LDI		Temp2, 'r'
	rcall	Print
	LDI		temp2, 'm'
	rcall	Print
	LDI		Temp2, 'o'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'a'
	rcall	Print
	LDI		Temp2, 'n'
	rcall	Print
	LDI		temp2, 'a'
	rcall	Print
	LDI		temp2, 'g'
	rcall	Print
	LDI		temp2, 'e'
	rcall	Print
	LDI		temp2, 'r'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print


	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, 'B'
	rcall	Print
	LDI		temp2, 'I'
	rcall	Print
	LDI		Temp2, 'T'
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'E'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'C'
	rcall	Print
	LDI		temp2, 'H'
	rcall	Print
	LDI		Temp2, 'L'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, '!'
	rcall	Print





Start_ADC2:
	ldi		temp1,0b01100010	;ADC2 Wählen
	out		ADMUX,temp1
	sbi		ADCSRA,ADSC
Wait_ADC2:
	sbic	ADCSRA,ADSC
	rjmp	wait_adc2
	;ADC Einlesen
	in		temp7,ADCL
	in		temp7,ADCH
	cbi		ADCSRA,ADSC

Lux:								;Lichtstärke abfragen
	CPI		temp7,200				;Vergleiche ADC1 Wert mit 153
	BRSH	zuloop					;Springe zu Loop wenn größer als 120 (wenig Licht)
	rjmp	Summ					;Summ ist ein Warnton
Zuloop:
	rjmp	Loop






;****Aufheizen****
Aufheizen:
	cbi		portb,1					;WarnLED aus schalten
	rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print

	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'U'
	rcall	Print
	LDI		temp2, 'F'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'I'
	rcall	Print
	LDI		temp2, 'Z'
	rcall	Print
	LDI		Temp2, 'E'
	rcall	Print
	LDI		temp2, 'N'
	rcall	Print
	rjmp	Loop

;****Alles iO***
Allesio:
	cbi		portb,1					;WarnLED aus schalten
	rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print

	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, 'A'
	rcall	Print
	LDI		temp2, 'L'
	rcall	Print
	LDI		Temp2, 'L'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'S'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'I'
	rcall	Print
	LDI		temp2, 'N'
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'O'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'D'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'U'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	rjmp	Loop



;****Niedrig****
Niedrig1:
	cbi		portb,1					;WarnLED aus schalten
	rcall	LCD_löschen

	LDI		temp2,0b10000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print

	
	LDI		temp2,0b11000000	;Zeile festlegen 0b10000000=Zeile 0 , 0b11000000=Zeile 1
	rcall	send_Befehl

	LDI		Temp2, ' '
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'i'
	rcall	Print
	LDI		Temp2, 'e'
	rcall	Print
	LDI		temp2, 'd'
	rcall	Print
	LDI		Temp2, 'r'
	rcall	Print
	LDI		temp2, 'i'
	rcall	Print
	LDI		Temp2, 'g'
	rcall	Print
	LDI		temp2, 'e'
	rcall	Print
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'e'
	rcall	Print
	LDI		temp2, 'm'
	rcall	Print
	LDI		Temp2, 'p'
	rcall	Print
	LDI		temp2, '.'
	rcall	Print
	rjmp	Loop

;			Unterprogramme
;-----------------------------------------------------------------


; Display Installieren
;**************************************************

Display_ini:
	rcall	Waitms20
	ldi		temp3,3
Widerholung:
	LDI		temp2,0b00000011
	Out		portd,temp2
	rcall	send
	dec		temp3
	brne	Widerholung
	LDI		temp2,0b00000010
	OUT		Portd,temp2
	rcall	send
	LDI		temp2,0b00101000
	rcall	Send_Befehl
	LDI		temp2,0b00001100
	rcall	Send_Befehl
	LDI		temp2,0b00000100
	rcall	Send_Befehl

	ret


;LCD Löschen
;*************************************************

LCD_Löschen:
	ldi		temp2,0b00000001
	rcall	Send_Befehl
	ret



;Aufs LCD schreiben
;*************************************************

Print:
	Mov		temp3,temp2
	swap	temp2
	andi	temp2,0b00001111
	sbr		temp2,0b00010000
	out		PortD,temp2
	rcall	send
	andi	temp3,0b00001111
	sbr		temp3,0b00010000
	OUT		Portd,temp3
	rcall	Send
	ret

;Instruktionen ans LCD
;*************************************************

Send_Befehl:
	Mov		temp3,temp2
	swap	temp2
	andi	temp2,0b00001111
	out		PortD,temp2
	rcall	send
	andi	temp3,0b00001111
	OUT		Portd,temp3
	rcall	Send
	ret	


;Warteschleifen
;************************************************
Waitms5:
	LDI		temp1,20
Waitms5_1:
	LDI		temp2,255
Waitms5_2:
	dec		temp2
	brne	waitms5_2
	dec		temp1
	brne	Waitms5_1
	ret
	


Waitms20:
	LDI		temp1,255
Waitms20_1:
	LDI		temp2,255
Waitms20_2:
	dec		temp2
	brne	waitms20_2
	dec		temp1
	brne	Waitms20_1
	ret


Waitms1:							;Waitms1 ist für die Tonhöhe des Warntons zuständig
	LDI		temp1,4
Waitms1_1:
	LDI		temp2,255
Waitms1_2:
	dec		temp2
	brne	waitms1_2
	dec		temp1
	brne	Waitms1_1
	ret
	
		

;Sendefreigabe
;************************************************
Send:

	SBI		portd,5
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	CBI		portd,5
	rcall	waitms5
	ret	



Summ:								;Summ ist für die Länge des Warntons zuständig
	LDI		r22,1
Summ1:
	LDI		r23,255
Summ2:
	sbi		portb,0
	rcall	waitms1
	cbi		portb,0
	rcall	waitms1
	dec		r23
	brne	Summ2
	dec		r22
	brne	Summ1
	rcall	Loop


Die Hardware ist momentan im Bau.

Hier mal ein Bildchen der Platine nach dem ätzen und verzinnen. (Löcher müssen noch gebohrt werden) ;)

Platine1.jpg

Die Stromversorgung und die Eingänge der PTCs laufen über eine RJ45 Buchse.

Für den dens interessiert, hier mal der Schaltplan:

Heizung Sch1.PNG

Wenns an den zusammenbau des Kästchens geht gibz nen weiteren Bericht ;)
 
Hier mal ein Bildchen der Platine nach dem ätzen und verzinnen. (Löcher müssen noch gebohrt werden) ;)


Hallo!

Die Platine sieht super aus. :hello:

Wie hast du die so gleichmäßig und sauber verzinnt bekommen?:hmmmm:
Bei mir will das mit Zinnpaste einfach nicht so richtig funktionieren.


Grüße,
Cassio
 
Code:
	LDI		Temp2, ' '
	rcall	Print
	LDI		temp2, 'T'
	rcall	Print
	LDI		Temp2, 'H'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		Temp2, 'R'
	rcall	Print
	LDI		temp2, 'M'
	rcall	Print
	LDI		Temp2, 'O'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print
	LDI		Temp2, 'M'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		Temp2, 'N'
	rcall	Print
	LDI		temp2, 'A'
	rcall	Print
	LDI		temp2, 'G'
	rcall	Print
	LDI		temp2, 'E'
	rcall	Print
	LDI		temp2, 'R'
	rcall	Print
	LDI		temp2, ' '
	rcall	Print

Wie wär's mit einer PrintString Routine?
 
@ Cassio

Die Platine hab ich mit "Chemisch Zinn" verzinnt. Die geätzte Platine wird einfach in eine Flüssigkeit gelegt in der aufgelöstes Zinn ist. das Zinn legt sich dann fest auf der Kupferplatine ab.

Die Flüssigkeit ist günstig herzustellen und hält ewig.
Chemisch Zinn gibz zb. hier zu kaufen
http://www.hood.de/angebot/34234126/chemisch-verzinnen-platinen-verzinnen-chemisch-zinn.htm

@wer
Eine Print String Routine? wie funktioniert das?
Gruß
 
Nochmal hi,

@wer
Eine Print String Routine? wie funktioniert das?
Du legst den Text einfach in nem Datenbereich des Flash ab (zB mit 0x00 als Endekennung wie unter Bascom oder C).
Dann sagst du ner Routine wo sie im Flash anfangen soll zu lesen und die arbeitet dann ab der Stelle Byte für Byte ab bis 0x00 gelesen wird. Das geht über die 16Bit Indexregister.

Code:
	ldi ZH,HIGH(2*testtxt) ;ZH/ZL auf Test-Meldung setzen
	ldi ZL,LOW(2*testtxt)  ;
	rcall usartprt		; String ausgeben


...

; ==================================================================
; ===== String aus Flash auf USART ausgeben ========================
; ==================================================================
usartprt:				; Gibt String auf LCD aus (0x00=Ende).
	push r16			; r16 auf Stack retten (fuer wiederherstellung)
	push r17			; r17 auf Stack retten (fuer wiederherstellung)

	ldi r17,255			; Ausgabezaehler loeschen
usartprtloop:			; Ausgabeschleife	
	lpm r16,Z+			; Zeichen laden und danach Pointer um +1 weiter
	cpi r16,0x00		; Test auf String-Ende (=0x00)
	breq usartprtend	; Ende des Textes
	rcall usartwr
	dec r17				; Ausgabezaehler -1
	brne usartprtloop	; weiter ausgeben

usartprtend:
	pop r17				; r17 wiederherstellen
	pop r16				; r16 wiederherstellen
	ret					; zurueck

...

.org 0x1F00	testtxt:
				;0123456789abcdef0123456789abcdef
			.db "the quick brown fox jumps over t"
			.db "he lazy dog 0123456789 THE QUICK"
			.db " BROWN FOX JUMPS OVER THE LAZY D"
			.db "OG 0123456789 ",0x00,0x00	;  3E00-3E6F (1F00) Modus A

etwa so.

Gruß
Dino
 
Hi

*Altes Thema raus kram* ;)

Ich bin noch immer an dieser verdammten Heizungsgeschichte dran. Mittlerweile wurde aus dem Textdisplay ein Grafikdisplay und aus ASM C (weil man eben doch schneller etwas abändern kann).

Ich hab nun ein sehr merkwürdiges Problem.
sobald ich in den Code den Timer Overflow Interrupt einbaue ignoriert das Programm die while Schleife. Es läuft also ununterbrochen die Main Schleife durch. Das soll natürlich nicht sein.
sobald ich jedoch die Interruptfreigabe "sei();" entferne wird die while Schleife wider ernst genommen.
Ich hab irgendwie die Vermutung dass der Timeroverflow einen reset erzeugt.
Hatte schonmal jemand das Problem?
-> hier mal die Main Schleife

Gruß

Code:
int main(void)
{
    	
    	for(volatile uint16_t i=0; i<15000; i++);			// Wait a little while the display starts up
    	ks0108Init(0);			// Initialize the LCD
    	
		
		
		
							//Bild Generieren
//************************************************************************************************		

		
		ks0108DrawRect(3, 17, 41, 43, BLACK);	// Kessel
		
		ks0108FillRect(64, 22, 18, 38, BLACK);	// Puffer 1 Füllung
		ks0108FillRect(85, 22, 18, 38, BLACK);	// Puffer 2 Füllung
		ks0108FillRect(106, 22, 18, 38, BLACK);	// Puffer 3 Füllung
		
		ks0108FillRect(65, 23, 16, Fuellung, WHITE);	// Puffer 1 Füllung
		ks0108FillRect(86, 23, 16, Fuellung, WHITE);	// Puffer 2 Füllung
		ks0108FillRect(107, 23, 16, Fuellung, WHITE);	// Puffer 3 Füllung
		
		ks0108DrawRect(6, 31, 35, 19, BLACK);	// Kessel Anzeige
		
		ks0108FillRect(75, 31, 38, 19, WHITE);	// Puffer Anzeige
		ks0108DrawRect(75, 31, 38, 19, BLACK);
		
		ks0108DrawLine(44, 57, 55, 58, BLACK);
		ks0108DrawLine(55, 57, 55, 18, BLACK);
		ks0108DrawLine(55, 17, 115, 17, BLACK);
		ks0108DrawLine(115, 18, 115, 22, BLACK);
		ks0108DrawLine(93, 18, 93, 22, BLACK);
		ks0108DrawLine(72, 18, 72, 22, BLACK);
		
		ks0108SelectFont(arial8, ks0108ReadFontData, BLACK);		// Select a font
		
		ks0108GotoXY(7,7);
		ks0108Puts_P(PSTR("KESSEL"));
		
		ks0108GotoXY(80,7);
		ks0108Puts_P(PSTR("PUFFER"));
		
		
		//	Temperaturen schreiben
		//*********************************
		
		ks0108SelectFont(Arial_Bold_14, ks0108ReadFontData, BLACK);		// Select a font
			
		ks0108GotoXY(9,35);		//Curserposition setzen
		ks0108Puts_P(PSTR("00*C"));		//Schreibe Kessel temperatur
		ks0108GotoXY(79,35);		//Curserposition setzen
		ks0108Puts_P(PSTR("00*C"));		//Schreibe Puffer Temperatur
		
		
		
//*************************************************************************************************
	
		//---------Timer Init-------------
		TCCR0 |= (1<<CS02) | (0<<CS01) | (0<<CS00);		
		TIMSK |= (1<<TOIE0);
		sei();	[COLOR="#FF0000"][B]<----------------------------------------------Problemquelle[/B][/COLOR]
		
		
		//---------ADC Init------------------
		ADMUX = (1<<REFS0) | (1<<ADLAR);	// Interne Referent / 10 Bit ADC linksbündig ausrichten
		ADCSRA = (1<<ADEN) | (1<<ADATE) | (1<<ADPS0) | (1<<ADPS1) | (1<<ADPS2); //ADC Einschalten, ADC Free Running Mode, Prescaler = 128
		ADCSRA |= (1<<ADSC);
		
		
		
		
    	while(1)
		{
			if (update==1)
			{
				update=0;
			
				ks0108FillRect(7, 32, 33, 17, WHITE);	// Kessel Anzeige löschen
				ks0108FillRect(76, 32, 36, 17, WHITE);	// Puffer Anzeige löschen
			
				ks0108SelectFont(Arial_Bold_14, ks0108ReadFontData, BLACK);		// Select a font
			
				//Kessel Temperatur
			
				ks0108GotoXY(9,35);		//Curserposition setzen
				ks0108PutChar(tempK_1);
				ks0108GotoXY(18,35);		//Curserposition setzen
				ks0108PutChar(tempK_2);
				ks0108GotoXY(26,35);		//Curserposition setzen
				ks0108Puts_P(PSTR("*C"));		//Schreibe °C
			
				//Puffer Temperatur
			
				ks0108GotoXY(79,35);		//Curserposition setzen
				ks0108PutChar(tempP_1);
				ks0108GotoXY(88,35);		//Curserposition setzen
				ks0108PutChar(tempP_2);	
				ks0108GotoXY(96,35);		//Curserposition setzen
				ks0108Puts_P(PSTR("*C"));		//Schreibe °C
			
			}
			
		}

}



// Timer Interrupt

ISR(TIMER0_OVF_vect)
{
	cnt++;
	if (cnt>=61)
	{
		update=1;
		cnt=0;
	}
	
	
}
 
Hallo,

ich finde leider nicht die Stelle wo du 'update' definiert hast. Das sollte auf jeden Fall 'volatile' sein, damit der Compiler weiss, dass diese Variable außerhalb von Main verändert werden kann und diese if-Abfrage nicht weg optimiert.

Dirk
 

Über uns

  • Makerconnect ist ein Forum, welches wir ausschließlich für einen Gedankenaustausch und als Diskussionsplattform für Interessierte bereitstellen, welche sich privat, durch das Studium oder beruflich mit Mikrocontroller- und Kleinstrechnersystemen beschäftigen wollen oder müssen ;-)
  • Dirk
  • Du bist noch kein Mitglied in unserer freundlichen Community? Werde Teil von uns und registriere dich in unserem Forum.
  •  Registriere dich

User Menu

 Kaffeezeit

  • Wir arbeiten hart daran sicherzustellen, dass unser Forum permanent online und schnell erreichbar ist, unsere Forensoftware auf dem aktuellsten Stand ist und der Server regelmäßig gewartet wird. Auch die Themen Datensicherheit und Datenschutz sind uns wichtig und hier sind wir auch ständig aktiv. Alles in allem, sorgen wir uns darum, dass alles Drumherum stimmt :-)

    Dir gefällt das Forum und unsere Arbeit und du möchtest uns unterstützen? Unterstütze uns durch deine Premium-Mitgliedschaft!
    Wir freuen uns auch über eine Spende für unsere Kaffeekasse :-)
    Vielen Dank! :ciao:


     Spende uns! (Paypal)