[bascom] Need Help for DataFlash
Hello,
I'm using Bascom-AVR 1.11.6.2, registered version. I'm trying to get
AT90S8515 uC to talk to DataFlash chip AT45DB041B, but I can't
get it working. I use 3.6V Vcc connect to the chip according to the
Dataflash datasheet. Below is how I connect the chip to the uC:
____________
PB5 -----------|SI SO|------------- PB6
PB7 -----------|SCk GND|------------- 0V
+5V -----------|~RST VCC|------------- +3.6V
PB4 -----------|~CS ~WP|------------- +5V
____________
I also use 10K pull up resister for the Chip_Select pin. And here is
part of my code I used:
$regfile = "8515DEF.DAT"
$crystal = 4000000
Const Cflash_status = &HD7 ' read flash
status
Dim Flashcmd(4) As Byte
Spiport Alias Portb
Const Chip_sel = 4
Config Spi = Hard , Data Order = Msb , Master = Yes , Clockrate =
4
Spiinit
Declare Sub Df_status
End
Sub Df_status:
Dim Datain As Byte
Flashcmd = Cflash_status
CBI Spiport,Chip_Sel ' enable DataFlash
Spiout Flashcmd , 1 ' send command
Spiin Datain , 1 ' read in data
SBI SPIPort,Chip_Sel ' disable
DataFlash
Home Upper
Lcd Datain
End Sub Df_status
This is what I thought I could check if I can talk to the DataFlash, by
asking for its status. But it always return 255 for the status instead
of 10011000 or the like as in the datasheet. Was I doing it right? or
is there any other ways to check if my DataFlash is still working, that
I haven't wrecked it.
Any help will be really appreciated.
Thank you in advance,
Regards,
Vanda.
p.s. Sorry about the ad about this message. It comes with the free
email I'm using.
---------------------------------------------------------------------
NEW EXCITING MESSAGE NOTIFICATIONS FROM mBox
Sign up for mBox Basic or Premium and receive it free!
http://www.mbox.com.au/mBeeper