MMC card using SPI on BX-24

Started by arhodes19044 November 5, 2005
Has anyone used a MMC card on a BX-24? I am trying to do it.

I have found that I can not use the built-in SPI functions because I
need to keep the Card-Select selected over a bunch of transfers, and
when the CS is deselected, apparently the transaction in progress is
lost. So, I used Tom Handy's bit-banged SPI routines. THANKS TOM! and I
got some results. I can communicate with the card in a minimal
way. Enough to know that it is not responding to the most basic
commands properly... I think.

Right now I am trying to use CMD0 (reset), CMD1 (initialize), and
CMD10 (get Card ID info).

The reset does not seem to give the return byte I expected, but I
get something. I then proceed to the Init and i might get a good
response. I then try to get the CID, but I get what I think is
garbage. It is almost correct garbage, but not quite.

Any proven code out there?

-Tony



CHECK OUT THIS DEVICE.. THEY ALSO HAVE A DEVICE TO SPI OR I2C OR RS-232
A MICRO TO A HARD DRIVE..

73
SPENCE
K4KEP

http://www.ghielectronics.com/ALFAT-SD.htm

Message: 3

> Date: Sat, 05 Nov 2005 22:36:28 -0000
> From: "arhodes19044" <spamiam@spam...>
>Subject: MMC card using SPI on BX-24
>
>Has anyone used a MMC card on a BX-24? I am trying to do it.
>
>I have found that I can not use the built-in SPI functions because I
>need to keep the Card-Select selected over a bunch of transfers, and
>when the CS is deselected, apparently the transaction in progress is
>lost. >So, I used Tom Handy's bit-banged SPI routines. THANKS TOM! and I
>got some results. I can communicate with the card in a minimal
>way. Enough to know that it is not responding to the most basic
>commands properly... I think.
>
>Right now I am trying to use CMD0 (reset), CMD1 (initialize), and
>CMD10 (get Card ID info).
>
>The reset does not seem to give the return byte I expected, but I
>get something. I then proceed to the Init and i might get a good
>response. I then try to get the CID, but I get what I think is
>garbage. It is almost correct garbage, but not quite.
>
>Any proven code out there?
>
>-Tony >________________________________________________________________________
>________________________________________________________________________
>
>Message: 4
> Date: Sun, 06 Nov 2005 13:34:42 -0000
> From: "guydb91" <guydebievre@guyd...>
>Subject: Midi problems
>
>hi,
>
>still new at BX-24...I am trying to send out MIDI data, using the
>information I found here. Unfortunately, instead of sending out what I
>intend to send out I send out a lot of nonsensical data on various
>MIDI channels (program changes, now and then a 'note on', after touch,
>etc...but mostly system resets). I tried 2 circuits, one with the
>2n2222 and one without (which always worked fine with the basic stamp.
>And yes, I a using com1 with the 'register.UBRR = 14' setting. any
>suggestions as to what I may be doing wrong?
>
>thanks.
>
>guy >
>
>________________________________________________________________________
>________________________________________________________________________ >
>
>Yahoo! Groups Links



--- In basicx@basi..., "BOYD S.(SPENCE) MINER" <k4kep@b...>
wrote:
>
> CHECK OUT THIS DEVICE..
> http://www.ghielectronics.com/ALFAT-SD.htm


It looks very nice and the price is not extreme. If I were looking
for a simple solution, I would go for something like this. There are
a couple of others around too.

But.... I am trying to get the BX to directly interface to the SD/MMC
card.

-Tony



Hey folks!

The ALFAT-SD works well and is easy to work with.
The unit is well supported with outstanding customer service.
I'm very glad I selected the ALFAT-SD.
Also check out their USB hosting devices!

Chuck



Chuck, I just purchased an Alfat board, and am having trouble
interfacing to it with a bx24--despite how simple it should be.

Do you have the 3.3V output of the Alfat going back to a 5V micro
successfully, or through a level-converter? (It's tolerant of 5V
inputs, but can the bx24 read 3.3V as high?)
Actually, you didn't say if you used it with a bx or not...

Anyone have tips on getting this system running with a bx24?

--- In basicx@basi..., "PFiX Controls" <chuck@p...> wrote:
>
> Hey folks!
>
> The ALFAT-SD works well and is easy to work with.
> The unit is well supported with outstanding customer service.
> I'm very glad I selected the ALFAT-SD.
> Also check out their USB hosting devices!
>
> Chuck
>




Concerning the ALFAT-SD board, make sure you download and install
the latest bootloader and ALFAT application software. GHI has improved
the SPI interface but they still recommend using the UART interface. Also,
check out their support forum. Many people, including me, have already
traveled the path you are taking and can help out. Although I used a Z8
microcontroller, which uses 3.3V, I believe the BX-24 should work fine.
Watch out for one BIG headache. The ALFAT-SD echoes any data you
transmit to it, so remember to read after every write until you have turned
off echo. You turn off echo by sending the letters, EE, but make sure you
read after each E. Also, don't try to send data if DATARDY is high. Read the
unit
until DATARDY goes low, then write.

Enough said about the ALFAT-SD. If you need more help go to GHI's web
site and study the forum responses. I'm sure you will find answers there.

Good luck,
Chuck


Thanks Chuck. Good pointer regarding the echo.

Actually I have read every single post on their forum:) I was hoping to find bx specific information, setting of com ports,
etc, since I can't seem to get the 9600 non-inverted com3 working
with the board. I simply cannot read the "BL" characters in com3,
which should be arriving at every Alfat powerup.

I posted on their forum, so hopefully someone there has gotten this
to work with a bx system.
--- In basicx@basi..., "PFiX Controls" <chuck@p...> wrote:
>
> Concerning the ALFAT-SD board, make sure you download and install
> the latest bootloader and ALFAT application software. GHI has
improved
> the SPI interface but they still recommend using the UART
interface. Also,
> check out their support forum. Many people, including me, have
already
> traveled the path you are taking and can help out. Although I used
a Z8
> microcontroller, which uses 3.3V, I believe the BX-24 should work
fine.
> Watch out for one BIG headache. The ALFAT-SD echoes any data you
> transmit to it, so remember to read after every write until you
have turned
> off echo. You turn off echo by sending the letters, EE, but make
sure you
> read after each E. Also, don't try to send data if DATARDY is high.
Read the
> unit
> until DATARDY goes low, then write.
>
> Enough said about the ALFAT-SD. If you need more help go to GHI's
web
> site and study the forum responses. I'm sure you will find answers
there.
>
> Good luck,
> Chuck
>


Make sure you connect CTS to ground if you are not using it.
Check your connections between the BX-24 and the ALFAT-SD.
The BX-24 TXD should be connected to the RXD on the ALFAT
and the BX-24 RXD should be connected to the TXD on the ALFAT.
If you are using DB9 connectors, try inserting a NULL MODEM to
see if this works.

To disable echo send, "EE 0" followed by &H0D. That's a space between
the EE and 0(zero).

If you haven't already tried it, you might try 9600, inverted just to be
sure.

Chuck


I'm getting closer:)

The bx can see BL on startup of the Alfat now. The Alfat tx pin
needed a pullup resistor...it's open collector I guess.

Here is a problem I'm having.

The following should send the character "V" (version query) out
com3. All queues are 25 bytes, more than enough.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~
do
'~~~~~~~~~~~~\
'place onto buffer
outstring = "V"
clearqueue inbuffer
clearqueue outbuffer
putqueuestr outbuffer, outstring
'~~~~~~~~~~~~/

'~~~~~~~~~~~~\
'wait for tx to complete:
do while statusqueue(outbuffer) = true
loop
do While ((RAMpeek(CuInt(Com3Status)) And TXC3) = TXC3)'UARTstatus
loop
'~~~~~~~~~~~~/ '~~~~~~~~~~~~\
'now read back the reply, which SHOULD be "3.0"
do
getqueue inbuffer, bvar, 1, 1.0, timeout
if timeout = FALSE then
debug.print chr(bvar);
else
'just restart transmit up above
exit do
end if
loop
'~~~~~~~~~~~~/

loop
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Yet, the first two times I read in "ER DE" (command error).

The third time I place "V" onto the queue, WITHOUT FAIL, I always
get back the correct "3.0". Same goes with the other commands.

ER DE
ER DE
3.0
3.0
...

Any thoughts on the BX end, or on the Alfat end, on what might be
causing the repeatable error?

Varied delays have no effect; it can be 10 seconds between sending
the V's, and it still understands only the third time.
By the way, I am using the Alfat-SD board which has no computer
interface, so the bx24 talks to it through com3. My apologies for the packed post.



Before sending any command to the ALFAT, always, examine
the DATARDY pin. If it is high, read the ALFAT, Delay(1), which
waits 2 msecs, then check DATARDY again. Loop thru this until DATARDY
is low. Then send the "V". The response will include the echo of the "V"
with
a carriage return(CR), then the "3.0" with another CR. In text mode, the
ALFAT sends CR along with the text response so always read the ALFAT,
with the 2msec delay until DATARDY stays low. Then send the next command.

What I did was check DATARDY and read until low. Then send a command,
and wait for DATARDY to go high. That way I knew the ALFAT had
responded to the command. I then loop thru reading the input, with the 2msec
delay, until
DATARDY goes low. Now I know that the input buffer has all the data the
ALFAT has sent back. I scan the input buffer for whatever response I
expected
or for the error response.

I hope this helps! Let me know any results.

Chuck