Seltsames BASCOM Atmega88 Problem

Programmierung und Hardwaredesign mit Arduino, AVR, PIC und Konsorten.

Moderatoren: MaxZ, ebastler, SeriousD

Antworten
Benutzeravatar

Thread-Ersteller
nsawilla
Beiträge: 1267
Registriert: Mi 14. Sep 2005, 09:30
Spezialgebiet: Elektronik, AVRs
Schule/Uni/Arbeit: TU Graz Elektrotechnik
Wohnort: Graz
Danksagung erhalten: 1 Mal
Kontaktdaten:

Seltsames BASCOM Atmega88 Problem

Beitrag von nsawilla »

FIRST THINGS FIRST: Wenn mich jetzt jemand anpöbelt warum ich BASCOM verwende und nicht C dann knallt es :aufsmaul:
Hab die gleiche Frage schon ins MSC BASCOM Forum gepostet, drum ist der Post ausnahmsweise auf Englisch: :mrgreen:
-----------------------
i'm currently working on a project based on interrupts, powersave mode and softclock and i experienced a very odd bug of some sort.
I'm using an ATmega88PA-PU running on it's internal 8Mhz RC-Oscillator, an EA-DOG-LCD and a 32kHz crystal connected to TOSC1 and TOSC2.

This is my initialisation:

Code: Alles auswählen

'init lcd 
Config Lcd = 16 * 2 , Chipset = Dogm162v5 , Contrast = &H74 
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portd.0 
Initlcd 
Cursor Off 
Cls 

'init timer 
Config Clock = Soft , Gosub = Sectic 
Enable Interrupts 

Dim Secs As Byte 
Dim Test As Byte
And this is the code snippet in question:

Code: Alles auswählen

'main loop 
Do 

If Secs = 2 Then 
Secs = 0 
Incr Test 
Cls 
Upperline 
Lcd Test 
Lowerline 
Lcd _sec 
End If 

Powersave 
Loop 
End 

'timer2 isr 
Sectic: 
Incr Secs 
Return
So what this should do: refresh the LCD every two seconds, the upper value (Test) should be half the value of _sec, displayed on bottom of the LCD.
But what it does: nothing. nothing at all. nothing is ever displayed.

BUT - and that is weird - it works perfectly well in the simulation, and it also works on an ATmega8!
And a more elegant implementation 'temp = secs MOD 2 : if temp = 0 then ..' works as well.

I also found a few workarounds for the M88 which i don't understand:
If i insert 'waitms 200' before the 'do' of the main loop it displays the correct numbers but it runs at double speed!
So the LCD is updated every second and the _secs value is two times higher than it should be!
If the waiting time is 'too short' (~100ms) it does not work..
If i then insert another "waitms 1" in the timer2 ISR everything works just as it should and it runs at correct speed, displaying the correct numbers!

And it also works fine without the waiting but by removing the 'Powersave' instruction from the loop!

Can anyone explain what's happening there? I already replaced the M88 and the crystal so the problem doesn't seem to be limited to my hardware.
Am i missing something? Is this a bug in the BASCOM software or is the M88 not as backwards compatible to the M8 as it should be?

I would be very happy about any help because i need this to work in this hard- and software configuration!
Furthermore this bug already made worthless the code i already wrote and i don't need any further surprises of this kind!

Best Regards!
Manch schwieriger Fall endet mit Blitz und Knall.. :mrgreen:

Ich hafte nicht für die inhaltliche Korrektheit meine Beiträge, sowie für Sach- oder Personenschäden.

alpin
Beiträge: 350
Registriert: Di 7. Jul 2009, 17:39
Danksagung erhalten: 1 Mal

Re: Seltsames BASCOM Atmega88 Problem

Beitrag von alpin »

Also, BASCOM hätte ich dafür nun nicht verwendet, eher Assembler.... :trollface:

sorry, ich habe keine Ahnung, aber verkneifen konnte ich mir das hier auch nicht ;)
Benutzeravatar

Thread-Ersteller
nsawilla
Beiträge: 1267
Registriert: Mi 14. Sep 2005, 09:30
Spezialgebiet: Elektronik, AVRs
Schule/Uni/Arbeit: TU Graz Elektrotechnik
Wohnort: Graz
Danksagung erhalten: 1 Mal
Kontaktdaten:

Re: Seltsames BASCOM Atmega88 Problem

Beitrag von nsawilla »

War das wirklich nötig?
:facepalm:
Manch schwieriger Fall endet mit Blitz und Knall.. :mrgreen:

Ich hafte nicht für die inhaltliche Korrektheit meine Beiträge, sowie für Sach- oder Personenschäden.
Benutzeravatar

SeriousD
Beiträge: 427
Registriert: Mi 26. Aug 2009, 22:16
Spezialgebiet: Handwerkliche Improvisationen
Wohnort: Kiel
Hat sich bedankt: 19 Mal
Danksagung erhalten: 41 Mal

Re: Seltsames BASCOM Atmega88 Problem

Beitrag von SeriousD »

alpin hat geschrieben:Also, BASCOM hätte ich dafür nun nicht verwendet, eher Assembler.... :trollface:
Quatsch eher C!
:trollface:
Hey Sigma, ist noch Lambda? - Ja aber das Phi ist noch Rho.

Manawyrm
Beiträge: 621
Registriert: Fr 18. Dez 2009, 22:18
Spezialgebiet: MCUs, HF, IT
Hat sich bedankt: 5 Mal
Danksagung erhalten: 5 Mal
Kontaktdaten:

Re: Seltsames BASCOM Atmega88 Problem

Beitrag von Manawyrm »

Also dann doch lieber Arduino als C :PPP
Antworten