Seite 1 von 1

Seltsames BASCOM Atmega88 Problem

Verfasst: Mi 12. Aug 2015, 12:41
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 
Cursor Off 

'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 

If Secs = 2 Then 
Secs = 0 
Incr Test 
Lcd Test 
Lcd _sec 
End If 


'timer2 isr 
Incr Secs 
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!

Re: Seltsames BASCOM Atmega88 Problem

Verfasst: Mi 12. Aug 2015, 14:19
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 ;)

Re: Seltsames BASCOM Atmega88 Problem

Verfasst: Mi 12. Aug 2015, 17:40
von nsawilla
War das wirklich nötig?

Re: Seltsames BASCOM Atmega88 Problem

Verfasst: Do 27. Aug 2015, 18:35
von SeriousD
alpin hat geschrieben:Also, BASCOM hätte ich dafür nun nicht verwendet, eher Assembler.... :trollface:
Quatsch eher C!

Re: Seltsames BASCOM Atmega88 Problem

Verfasst: Sa 29. Aug 2015, 19:32
von Manawyrm
Also dann doch lieber Arduino als C :PPP