Jag upptäckte det med hastigheten för 2 minuter sedan också
Måste ha varit SBS (Skit Bakom Spakarna) innan...
Jag avkopplade lite bättre, och då gick det med lägre hastigheter.
Det men dina trasiga minnen, det känns ju knappast att de skulle vara döda från början, det kan mycket väl vara din lödkolv...
Eller Lucas eller så var det måndags ex...
Nu ska jag försöka skriva lite data till minnet, och se hur det fungerar.
CON
'--- 80 MHz ---
_clkmode = xtal1 + pll16x ' PLL
_xinfreq = 5_000_000 ' Crystal 5 MHz
SI = 0 ' FlashMem: Serial Data Input
SCK = 1 ' FlashMem: Serial Clock
SO = 2 ' FlashMem: Serial Data Output
CE = 3 ' FlashMem: Chip Enable
PIN_MASK = (1<<SI) | (1<<SCK) | (1<<CE)
PUB Main
Init ' Set pin direction states and initialize SCK, CE
WREN ' Enable the Write Enable Latch
WRSR($00) ' Disable all Block Write Protection
WREN ' Enable the Write Enable Latch
Sector_Erase($000000) ' Sector Erases the Chip
Wait_Busy ' Waits until device is no longer busy
WREN ' Enable the Write Enable Latch
Byte_Program($000000,$01) ' Write byte to adress
StatusLeds(Read($000000)) ' Read byte from adress
repeat ' Keep the processor alive.
PRI StatusLeds(status)
dira |= $FF00 ' Pin 15~8
outa[15..8] := status
PUB Init
dira := PIN_MASK ' Set pin direction states
outa[SCK] := 0 ' Set clock to low initial state
CE_High ' Disable device, set CE high
PUB WREN
'' This procedure enables the Write Enable Latch.
'' It can also be used to Enables Write Status Register.
CE_Low ' Enable device, clear CE low
Send_Byte($06) ' Send WREN command
CE_High ' Disable device, set CE high
PUB WRDI
'' This procedure disables the Write Enable Latch.
CE_Low ' Enable device
Send_Byte($04) ' Send WRDI command
CE_High ' Disable device
PUB EWSR
'' This procedure Enables Write Status Register.
CE_Low ' Enable device
Send_Byte($50) ' Enable writing to the status register
CE_High ' Disable device
PUB RDSR | byte_
'' This procedure read the status register and Returns the byte.
CE_Low ' Enable device, clear CE low
Send_Byte($05) ' Send RDSR command
byte_ := Get_Byte ' Receive byte
CE_High ' Disable device, set CE high
result := byte_
PUB WRSR(byte_)
'' This procedure writes a byte to the Status Register.
'' Input: byte
'' Returns: Nothing
CE_Low ' Enable device.
Send_Byte($01) ' Select write to status register.
Send_Byte(byte_) ' Data that will change the status of BPx
' or BPL (only bits 2,3,4,5,7 can be written).
CE_High ' Disable the device
PUB WREN_Check | byte_
'' This procedure checks to see if WEL bit set before program/erase.
'' Input: None
'' Returns: Boolean
byte_ := RDSR ' Read the status register
if byte_ & $02 ' Verify that WEL bit is set
result := true
else
result := false
PUB Wait_Busy
'' This procedure waits until device is no longer busy (can be used by
'' Byte-Program, Sector-Erase, Block-Erase, Chip-Erase).
repeat while ((RDSR & $03) == $03) ' waste time until not busy
RDSR
PUB Sector_Erase(Dst)
'' This procedure Sector Erases the Chip.
'' Input: Dst: Destination Address 000000H - 0FFFFFH
'' Returns: Nothing
CE_Low ' enable device
Send_Byte($20) ' send Sector Erase command
Send_Byte(((Dst & $FFFFFF) >> 16)) ' send 3 address bytes
Send_Byte(((Dst & $FFFF) >> 8))
Send_Byte(Dst & $FF)
CE_High ' disable device
PUB Byte_Program(Dst,byte_)
'' This procedure programs one address of the device.
'' Assumption: Address being programmed is already erased and is NOT block protected.
'' Input: Dst: Destination Address 000000H - 0FFFFFH
'' byte: byte to be programmed
'' Returns: Nothing
CE_Low ' Enable device
Send_Byte($02) ' Send Byte Program command
Send_Byte(((Dst & $FFFFFF) >> 16)) ' Send 3 address bytes
Send_Byte(((Dst & $FFFF) >> 8))
Send_Byte(Dst & $FF)
Send_Byte(byte_) ' Send byte to be programmed
CE_High ' Disable device
PUB Read(Dst): byte_
'' This procedure reads one address of the device.
'' It will result the byte read in variable byte.
'' Input: Dst: Destination Address 000000H - 0FFFFFH
'' Returns: byte
CE_Low ' enable device
Send_Byte($03) ' read command
Send_Byte(((Dst & $FFFFFF) >> 16)) ' send 3 address bytes
Send_Byte(((Dst & $FFFF) >> 8))
Send_Byte(Dst & $FF)
byte_ := Get_Byte
CE_High ' disable device
result := byte_ ' result one byte read
PRI CE_High
'' This procedure set CE = High.
outa[CE] := 1 ' set CE high
PRI CE_Low
'' This procedure drives the CE of the device to low.
outa[CE] := 0 ' clear CE low
PRI Send_Byte(out) | i
repeat i from 0 to 7 ' for (i = 0 i < 8 i++)
if (out & $80) == $80 ' check if MSB is high
outa[SI] := 1
else
outa[SI] := 0 ' if not, set to low
outa[SCK] := 1 ' toggle clock high
out := (out << 1) ' shift 1 place for next bit
outa[SCK] := 0 ' toggle clock low
PRI Get_Byte | i,in,temp
in := 0
repeat i from 0 to 7 ' for (i = 0 i < 8 i++)
in := (in << 1) ' shift 1 place to the left or shift in 0
temp := ina[SO]
outa[SCK] := 1 ' toggle clock high
if temp == 1 ' check to see if bit is high
in := in | $01 ' if high, make bit high
outa[SCK] := 0 ' toggle clock low
result := in
PRI Delay(ms)
waitcnt(80_000*ms + cnt)
Senast redigerad av BEEP 18 mars 2010, 12:31:17, redigerad totalt 8 gånger.
jesse: SPIN och Propeller
Eftersom det är ganska enkelt att porta över enklare C kod till SPIN så tror jag inte att det är så likt Basic men jag har bara skrivit lite Basic på hobbydatorerna som fanns på 80 talet så vad vet jag.
BEEP: jag funderar på att börja titta på mina minnen så småningom.
undrar bara - du som gjort en fungerande kod för AVR - du använder tydligen det inbyggda SPI-interfacet. Är det så att man adresserar minnet på något vis så man kan koppla på andra sakar på samma trådar eller hur fungerar det där?
Vill både ha minne och en extern SPI-anslutning om det kan fungera att kombinera? Ser att det finns en pinne som heter "SS - slave select" på AVR'en... så det kanske bara är att använda en "slave-select"-tråd för varje enhet som ska kommuniceras med och se till att den multiplexas till rätt enhet från SS-pinnen? Den kopplar jag väl bara till CE# på minnet så ska väl det fungera?
EDIT: och så HOLD# pinnen... är den nödvändig eller går det att dra den till + ?
Jag kan väldigt lite om SPI så jag hoppas att det jag skriver är korrekt.
När det gäller våra SST minnen så har dom ingen enhetsadressering i protokollet eller vad det nu heter, så man använder CE kopplad till en valfri utgång på AVR'en för att aktivera det minne som man vill prata med. SO, SI och SCK linjerna delar minnena med varandra. Är dina SPI enheter slavar med CE ingång så gör du likadant med dom också.
"Ser att det finns en pinne som heter "SS - slave select" på AVR'en..."
Om jag inte har fel så används SS som ingång när AVR'en är en SPI slave?
"EDIT: och så HOLD# pinnen... är den nödvändig eller går det att dra den till + ?"
Just nu så är jag ute på jobb så jag kan inte kolla upp det men om du tittar på SST minnet så ser du att HOLD och WP är kopplat till plus eller minus.
Senast redigerad av BEEP 19 maj 2009, 06:10:07, redigerad totalt 1 gång.
OK, tack för svaret. Verkar inte så krångligt då. Tar nog ett par veckor innan jag kommit så långt att jag börjat bygga min testboard med Atmega48. Jag ska ha lite blandat - bl.a. LCD-display (utbytbar med annan device, tex 7-segm displayer), UART 5V, RS485, RS232, utgång för MOSFET-gate, summer, ett par knappar, kanske en IR-mottagare (fjärrkontroll) samt ett flashminne att logga data i.
Flashminnet kommer jag att ansluta bland det sista jag gör. Tänkte cadda kortet så att jag kan limma på det lilla minneskortet på mitt PCB och bygla över anslutningarna på nåt vis. Alternativet , om man har platsbrist är väl att helt enkelt löda av kretsen från det lilla kortet. Är väl inte så besvärligt egentligen.
BEEP skrev:
Tyvärr så är minnet lika dött med din kod på AVR sidan så jag ska ta och prova med ett nytt minne, kanske var det min katt Lucas som släckte ljuset när han var framme och nosade på kopplingarna.
Idag så släcktes ljuset för Lucas efter att hans njurar hade lagt av.
Eftersom han var en extremt go tillgiven katt så var det hemskt att avliva honom, RIP
Du har inte behörighet att öppna de filer som bifogats till detta inlägg.