Forum: Mikrocontroller und Digitale Elektronik *noob* Bascom und time$


von Mats M. (elektrofreak)


Lesenswert?

Nabend.

Ich hab nur ne kleine Frage, die ich aber trotzem selber noch nicht 
lösen konnte. Es wäre schön, wenn jemand mir ganz ohne vorwürfe, dass 
diese Frage irgendwo schon gelöst wurde oder ähnlichem beantwortet.


Brauche ich bei Bascom eine Unterprozedur, welche die Uhrzeit Time$ 
aktualisiert? Bei mir bleibt die Zeit immer Stehen, d.h. bei 
Simulationen ändert sich die Uhrzeit nie. auch wait 1 oder ähnliche 
Befehle bringen immer wieder die vorher eingestellte uhrzeit zutage. Ich 
habe vermutet, dass Bascom/der Controller selber die Uhrzeit erhöhen 
würde.

vielen Dank für die Beantwortung der Frage.

M.f.G.

Elektrofreak

von E. B. (roquema) Benutzerseite


Lesenswert?

Wie soll Dir jemand helfen, wenn Du nicht Deinen Quelltext preisgibst?
Was steht denn in der Bascom Hilfe zu "time$"?

von Mats M. (elektrofreak)


Lesenswert?

1
$regfile = "m128def.dat"
2
3
$crystal = 8000000
4
$baud = 19200
5
6
Enable Interrupts
7
8
'[now init the clock]
9
Config Date = Mdy , Separator = /                           ' ANSI-Format
10
11
Config Clock = Soft                                         'this is how simple it is
12
'The above statement will bind in an ISR so you can not use the TIMER anymore!
13
14
'assign the date to the reserved date$
15
'The format is MM/DD/YY
16
Date$ = "11/11/05"
17
18
'assign the time, format in hh:mm:ss military format(24 hours)
19
'You may not use 1:2:3 !! adding support for this would mean overhead
20
'But of course you can alter the library routines used
21
22
Time$ = "23:59:50"
23
Do
24
    Waitms 500
25
    Print Date$ ; Spc(3) ; Time$
26
Loop
27
End

Eigendlich sollte das klappen; es ist das aus der Hilfe ohne 
LCD-Ansteuerung. Komischerweise bekomme ihc hier die Fehlermeldung:
"Label not found[Tring1"2          ]. Das hat mich jetzt völlig aus dem 
Konzept geworfen... (Es heißt ja auch nicht String1, sondern Tring1)

von Düsentrieb (Gast)


Lesenswert?

rtfm:

 The compiler also creates an ISR that gets updates once a second. This 
works only for the
 8535, M163 and M103 and M603, or other AVR chips that have a timer that 
can work in
 asynchrony mode.
 For the 90S8535, timer2 is used. It can not be used my the user 
anymore! This is also true
 for the other chips async timer.
 Notice that you need to connect a 32768 Hz crystal in order to use the 
timer in async mode,
 the mode that is used for the clock timer.

also: 32khz quartz dran?

von Mats M. (elektrofreak)


Lesenswert?

oh, hab ich gar nicht gesehen.

Also ich wollt einen AMTega32 verwenden. verstehe ich das richtig, dass 
der 32kHz-Quarz keinen einfluss auf die interne Taktfrequenz hat 
(solange man nichts an den Fusebits ändert) und dieser dann nur für die 
Uhrzeit/Datum verwendet wird?

von Düsentrieb (Gast)


Lesenswert?

jup
die uhr kann somit unabhängig laufen , strom-sparend

timer2:
• Allows clocking from External 32 kHz Watch Crystal Independent of the 
I/O Clock

von Mats M. (elektrofreak)


Lesenswert?

Noch ne Frage:

Ist es richtig wenn ich davon Ausgehe, dass am XTal2 und XTal2 nur 
Crystals hängen, um die Frequenz des Controllers bei gesetzten Fusebits 
zu verändern und an TOSC1 und TOSC2 der Crystal kommt, damit der Timer2 
funktioniert?
1
For AVR microcontrollers with Timer/Counter Oscillator pins (TOSC1 and TOSC2), the crystal is
2
connected directly between the pins. No external capacitors are needed. The Oscillator is optimized for use with a 32.768kHz watch crystal. Applying an external clock source to TOSC1 is
3
not recommended.

d.h. auch dass an XTal1,2 kein Crystal muss, wenn ich mit den internen 
8MHz zufrieden bin?

von Mats M. (elektrofreak)


Lesenswert?

Ich hab mich jetzt dazu entschieden ein externes IC zu verwenden, 
welches auch die Uhrzeit bei abgeschalteter Versorgungsspannung 
speichert. Es handelt sich hier um den PCF8583. Somit habe ich den Timer 
noch frei und kann ggf. den Port auch für andere Sachen verwenden. Ich 
hoffe das auslesen wird nicht das Problem ;-)

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.