Xeus
28.12.2004, 13:21
Hallo, Ich hab an meinem mega8 einen max7219 angeschlossen, der ein 3digit dis ansteuert.
den max hab ich wiefolgt an den mc angeschlossen:
DIN----------------------MOSI (PB3)
CLK----------------------SCK (PB5)
LOAD--------------------PB2
hier der Quellcode:
$regfile = "m8def.dat"
$crystal = 1000000
Disp_en Alias Portb.3 ' chip-select for display driVer
Ser_clk Alias Portb.5 ' clk for display driver
Ser_data Alias Portb.2 ' data for display driver
Dim Disp_num As Byte
Dim Disp_data As Byte
Gosub Max7219_setup
Main:
Disp_num = 1 ' ( 0 - 7 ) digit#
Disp_data = 5 ' (0 - 15 ) number to display.
Gosub Disp_write
End
' setup max7219 config. registers
Max7219_setup:
Disp_num = &H0C : Disp_data = 0 ' Shutdown On
Gosub Disp_write
Disp_num = 9 : Disp_data = &B0011_0111 ' Decode "B" For 1st 6
Gosub Disp_write
Disp_num = &H0A : Disp_data = &H0F ' Brightness Full
Gosub Disp_write
Disp_num = &H0B : Disp_data = 7 ' # Digits 8
Gosub Disp_write
Disp_num = &H0F : Disp_data = 0 ' Test Off
Gosub Disp_write
Disp_num = &H0C : Disp_data = 1 ' Shutdown Off
Gosub Disp_write
Return
' Sends data to the Max7219 display driver
Disp_write:
Disable Interrupts
Reset Ser_data
Reset Ser_clk
Reset Disp_en
Shiftout Ser_data , Ser_clk , Disp_num , 1
Shiftout Ser_data , Ser_clk , Disp_data , 1
Set Disp_en
Enable Interrupts
Return
Aber irgendwas funzt nicht, das display zeigt mir nur zwei 9 und die dots an.
FOTO (Anhang)
Bin schon kurz vorm verzweifeln.
gruß,
xeus
den max hab ich wiefolgt an den mc angeschlossen:
DIN----------------------MOSI (PB3)
CLK----------------------SCK (PB5)
LOAD--------------------PB2
hier der Quellcode:
$regfile = "m8def.dat"
$crystal = 1000000
Disp_en Alias Portb.3 ' chip-select for display driVer
Ser_clk Alias Portb.5 ' clk for display driver
Ser_data Alias Portb.2 ' data for display driver
Dim Disp_num As Byte
Dim Disp_data As Byte
Gosub Max7219_setup
Main:
Disp_num = 1 ' ( 0 - 7 ) digit#
Disp_data = 5 ' (0 - 15 ) number to display.
Gosub Disp_write
End
' setup max7219 config. registers
Max7219_setup:
Disp_num = &H0C : Disp_data = 0 ' Shutdown On
Gosub Disp_write
Disp_num = 9 : Disp_data = &B0011_0111 ' Decode "B" For 1st 6
Gosub Disp_write
Disp_num = &H0A : Disp_data = &H0F ' Brightness Full
Gosub Disp_write
Disp_num = &H0B : Disp_data = 7 ' # Digits 8
Gosub Disp_write
Disp_num = &H0F : Disp_data = 0 ' Test Off
Gosub Disp_write
Disp_num = &H0C : Disp_data = 1 ' Shutdown Off
Gosub Disp_write
Return
' Sends data to the Max7219 display driver
Disp_write:
Disable Interrupts
Reset Ser_data
Reset Ser_clk
Reset Disp_en
Shiftout Ser_data , Ser_clk , Disp_num , 1
Shiftout Ser_data , Ser_clk , Disp_data , 1
Set Disp_en
Enable Interrupts
Return
Aber irgendwas funzt nicht, das display zeigt mir nur zwei 9 und die dots an.
FOTO (Anhang)
Bin schon kurz vorm verzweifeln.
gruß,
xeus