Forum: Mikrocontroller und Digitale Elektronik Uhrenquarz am Atmega2561 nutzen


von Jürgen E. (joe73)


Lesenswert?

Hallo,

Habe hier ein Board von Display3000 mit einem Atmega2561. Der Uhrenquarz 
ist ebenfalls bestückt.
Kann mir jemand mal aufzeigen wie ich den Quarz nutzen kann, z.B. einen 
Sekundentakt erzeugen? Es sollte z.B. jede Sekunde ein Int. ausgelöst 
werden welcher die höchst mögliche Priorität im System hat.

Leider bin ich des Englischen nicht so mächtig.

Vielen Dank im voraus...

mfg Jürgen

: Verschoben durch Moderator
von Kurt (kurtcontroller)


Lesenswert?

Hi Jürgen,
probiere mal.

$hwstack = 64
$swstack = 128
$framesize = 16

$regfile = "m2561def.dat"
$crystal = 16000000
'#########################
'4 - Definition of used ports and pull up resistors
                                                            'At our 
boards we are using Port B for the SPI-communication to the LCD.
                                                            'Now we need 
to select Port B as to an output port (data output to the display)
Ddrb = &B01100110                                           'DDR = Data 
direction register; Port B1, B2, B4, B5, B6 switched to output (1) as 
needed by the display .B7 neu an aus...
Portb = &B10001001                                          '... the 
other ports of Port B are inputs with switched on pull up resistors

Ddra = &B00000000                                           'switch all 
8 Ports of Port A to input (0), Pin (PA.0 - PA.7)
Porta = &B11111111                                          'All port 
pins have individually selectable pull-up resistors. Here we enable 
these pull-up-resisitors, so these Pins are always at logical 1
                                                            'You need to 
pull these Pins against ground (GND)
Ddrc = &B00000000                    'switch all Ports of Port C to 
input
Portc = &B11111111                   'all pull-up-Resistors turned on

Ddrd = &B00000000                    'switch all Ports of Port D to 
input
Portd = &B11111111                   'all pull-up-Resistors turned on

Ddre = &B00000000                    'switch all Ports of Port E to 
input
Porte = &B11111111                   'all pull-up-Resistors turned on

Ddrf = &B00000000                    'switch all Ports of Port F to 
input
Portf = &B11111111                   'all pull-up-Resistors turned on

Ddrg = &B00000000                    'switch all Ports of Port G to 
input
Portg = &B11111111                   'all pull-up-Resistors turned on

$include Init21_display3000.bas

Enable Interrupts
' Display PWM
Config Timer1 = Pwm , Pwm = 8 , Compare C Pwm = Clear Up , Compare C Pwm 
= Clear Down , Prescale = 1

Config Clock = Soft
Config Date = Dmy , Separator = .

Date$ = "04.02.09"
Time$ = "17:35:00"


Call Lcd_print( "LCD UHR" , 1 , 0 , 2 , 2 , 2 , Dark_red , White) 
'font 1, double height & width


do
.... eigene Prog-Zeilen
Call Lcd_print(date$ , 15 , 74 , 1 , 2 , 2 , Bright_yellow , Black)
Call Lcd_print(time$ , 15 , 93 , 1 , 2 , 2 , Bright_yellow , Black)
....
loop
end

$include Glcd21_display3000.bas

$include Glcd21_fonts.bas
'Dummy Data um Fehlermeldungen bei der Kompilierung der Standardroutinen 
zu vermeiden
'Die Tabelle wird dann bei Nutzung eines indizierten Grafikdatei mit 
"echten" Daten ausgetauscht
Colortable:
Data 0

Gruß
Kurt

von Jürgen E. (joe73)


Lesenswert?

Hallo Kurt,

bin leider aus Zeitmangel noch nicht zum Testen gekommen,
vielen Dank aber für die Hilfe, wenn auch etwas verspätet...
(meinen Dank meine ich)
Gruß Jürgen...

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.