Kod: Zaznacz cały
$crystal = 11059200
Config Spi = Soft , Din = P1.1 , Dout = P1.2 , Cs = P1.0 , Clk = P1.3 , Data Order = Msb , Spioutedge = Rising
Spiinit 'Inicjalizacja SPI oraz portów.
Dim A(10) As Byte , X As Byte
'instrukcje pamieci
Const Write_enable = &B00000110
Const Write_disable = &B00000100
Const Read_status_register = &B00000101
Const Write_status_register = &B00000001
Const Read_from_memory_array = &B00000011
Const Write_to_memory_array = &B00000010
A(1) = Write_enable
A(2) = Write_to_memory_array
A(3) = &H02
A(4) = &H0A 'adres pamieci
A(5) = &H55 'dana
A(6) = Write_disable
Spiout A(1) , 6 'wysylanie 6 bajtow instrukcji i danej
End
[ Dodano: 14-06-2007, 12:53 ]
dobra sam sobie odpowiem na pytanie trzeba to napisac tak:
Kod: Zaznacz cały
$crystal = 11059200
Config Spi = Soft , Din = P1.1 , Dout = P1.2 , Cs = P1.0 , Clk = P1.3 , Data Order = Msb , Spioutedge = Rising
Dim A(10) As Byte , X As Byte
'instrukcje pamieci
Const Write_enable = &B00000110
Const Write_disable = &B00000100
Const Read_status_register = &B00000101
Const Write_status_register = &B00000001
Const Read_from_memory_array = &B00000011
Const Write_to_memory_array = &B00000010
A(1) = Write_enable
A(2) = Write_to_memory_array
A(3) = &H00 'adres pamieci
A(4) = &H00 'adres pamieci
A(5) = &H24 'dana
A(6) = Write_disable
Spiinit 'Inicjalizacja SPI oraz portów.
Reset P1.0 'cs na low
Spiout A(1) , 1 'write enable aby mozeliwe bylo zapisywanie
Set P1.0 'cs na high
Reset P1.0 'cs na low
Spiout A(2) , 4 'wyslanie instrukcji zapisu adresu i danej
Set P1.0 'cs na high
Reset P1.0 'cs na low
Spiout A(6) , 1 'konczy zapisywanie
Set P1.0 'cs na high
End