Card reader mode

Good afternoon,

I am here again to ask for guidance. I am using the ALFAT-SDR card, and I am accessing it via I2C. I have everything up and running, and I can send commands and receive responses via the I2C. I have it plugged into my target board via the 18 pin header. I can initialize the card, read/write files to/from it. everything seems kosher. My problem seems to be Card Reader mode.

If I have the SDR card plugged into the EVAL card and connect the EVAL card to one USB port on my computer and X2 on the SDR to another. I can call up the ALFAT explorer program and initialize the card for card reader mode, high speed. The computer recognizes the card reader mode and displays a window with a choice of what I want to do with the newly discovered device.
Now I take and unplug the SDR card from the EVAL board. Plug it into my host circuitry and start the host up. Through a couple of breakpoints in my emulation software, i can see that I have read the banner properly, sent the I D:H<0x0A> command, read the !00<0x0A> response and a few seconds later the computer comes up with a balloon that states that that it cannot recognizable the device on the USB port. I did not remove the cable from the SDR card but no matter how many times I plug it in and out, it does not recognize it. Does something else happen on the EVAL board that I am not aware of.
Thanks for any advice.
Steve

@ Bad Steve -

When plug the ALFAT board into EVAL, did you still use I2C or UART?

Try to connect wires and use I2C on EVAL board to see what happen, pls?

@ Dat

When I plug the SDR card into the EVAL board, I use the ALFAT explorer program, hence I am using the UART.

If I wire the I2C to the Eval/SDR combo, I will also have to wire the configure lines and reset so that I can make sure I come out of a reset and get the chip to recognize the I2C. Do you suspect any conflicts with the Alfat? This is the weekend, so I will try this on Monday morning. thanks

Steve

Well this morning a connected the entire EVAL/SDR card set to my host. Again I got the banner via I2C and saw the response from the code in my program

sprintf(buffer, “I D:H\n”);
data_out = WriteAlfat(buffer);

The computer still does not recognize the USB device! I do not understand why, I guess I am off to research the proper steps the computer takes to discover a device on the USB port. I also checked the Eval/SDR combo as a stand alone with the ALFAT explorer and it did recognize it. Thanks in advance for anyone’s input/advice.

Steve

Just some more info, though I am not sure that it tells us anything.

In the Alfat explorer, after it discovers the USB card reader mode (this is accomplished very quickly) I read the 0 register and get beck 0xD1.

In the I2c mode after I send the "I D:H<0x0A>, I read the 0 register and receive back 0x91. The difference, according to my interpretation of the owner’s manual is that U1 is not “attached”. I do not know if that gets set after windows recognizes the device or if it needs to be set for windows to recognize the device.

Anyone?

@ Bad Steve -

Hi Steve,

I just have done a quick test in ALFAT SDR, using EVAL with I2C, of course SCL and SDA are connected.

The I2C master I am using is EMX.

Everything works fine.

I also note that should send “I D:H\n” because HS PHY is connected. If send “I D:” only then your case can be happened.

So if you have I2C analyzer, then you can check if ALFAT received them all.

Below is EVAl board I just used to test I2C and SPI.

I2C is socket with all yellow wires. SPI is the one with black wires. and SPI socket, I pull chip select is high to get I2C interface.

If you have any GHI NETMF like EMX then I can send you my code.
Only thing I can think now is, somehow, ALFAT can not get the param “H”. Try to send single bytes instead of array.

@ Dat,

Thanks again for all the help. I realize it is difficult to do when everything you have works fine. I am sure it is something I am doing, but I do not understand what. I have followed your advice and retried sending the string as individual characters. There was no change in the response or activity of the computer.I am at a loss, the manual states that if you get back the !00<0x0A>, then the command was successful.

While writing this I had an idea. the command must be working if the computer is returning that the USB device is unrecognizable, no? To prove this, I initialized the sd card, I was able to see all the files on the card. I then unplugged and replugged the USB cable connected to X2 on the SD card. The computer did not come back with an unrecognizable device, because it was not in card reader mode. Do I need some sort of USB driver that I do not have installed maybe? Any thoughts on that?

Steve

P.S. Here is a pic of my setup.

@ Bad Steve -

Yes, the command “I D:h” should be independent on computer or connection. You can send the command after or before plug the cable in.

I am unclear about this, do you mean 'I S" command to initialize the sd? if so how you see all files?

Also, if UART is working it mean no driver needed.

Both “I D:” and “I D:h” will return “!00\n”. Some users can develop their project from ALFAT SoC and they may don’t need HS PHY. That is why “I D:” is still needed.

I still think for some reason master asked ALFAT initialize SD reader in FS instead of HS mode.

How about if send “I D:”, get !00 then send “I D:h”?

Or keep your setup as your image, but now connect UART TX and RX and try with UART interface, please?

@ Dat -

Do you have I2C analyzer to see what string master sent to ALFAT?

Review all your I2C code to make sure that the param “H” is not cut out somewhere.

Another way to test it, that is

Keep ALFAT is in EVAL board, you just need to connect SDA, SCL and GND from your board to ALFAT.

ALFAT is powered by EVAL board. If the master I2C is setup correctly then there is no reason to say that ALFAT does not work. :think:

@ Dat

Let me explain again, sometimes I am not clear when trying to get the point across. I have hooked to the SDR/eval combo, a microchip controller via I2C. Also hooked to the microchip controller is a USB interface for testing purposes. I can connect a terminal program to the USB and manipulate the controller via USB commands that I program into the controller.

If I initialize the SDR card using the command “I M:<0x0A>” via the I2C bus, I can talk to the SD card. I can prove this by having the USB port command to list all the files on the SD card. When I do this six files get listed in the terminal window that are on the SD card. So to me that proves I am properly communicating with the ALFAT using the I2c. Also while I am in this configuration, I can plug and unplug the USB cable attached to the SDR card via X2 and the computer never comes back with the “Unrecognizable USB device” balloon.

Now when I send the command “I D:H<0x0A>” via the I2C to the SDR card, I get back the “!00<0x0A>” response and every time I plug in the cable from X2 on the SDR card to the computer’s USB, I get the balloon that says “Unrecognizable USB device”. So that tells me the command is recognized via the I2C.

ANSWERS to your last couple of questions:
I do not have an I2C analyzer
I have tried sending individual characters to the I2C and I get back the successful command response
I have tried your suggestion of sending “I D:” then “I D:H”; this did not work either.

This afternoon I will try a few more things.
I will try another computer and I will try reconnecting the UART to the board and testing in that mode.

And again thank you for taking all the time to help me.

@ Bad Steve -

I understand your I2C is working correctly, because you can read “!00”.
Only thing relates to software is, make sure that “H” is included when call “I D:H”. You included “H” but there iis no way to sure 100% ALFAT got it unless we can see ACK in analyzer. But following what you said, it looks fine. This is just a notice, never mind if you think they are OK.

Also about hardware, there is no conflict between I2C and SD Card reader as we tested here. That is why in last post, I asked you to test: Connect SCL, SDA, GND from your board to ALFAT, and ALFAT is powered by external power or EVAL board. That is easy to find out what problem is.

You don’t need to change the PC if UART is working on that one.

Dat

Switching the hardware over to the UART, enabled me to get the card reader mode set up. Switching back to I2C, it failed again. Still not sure why?

Steve

@ Bad Steve -

[quote]
“Connect SCL, SDA, GND from your board to ALFAT, and ALFAT is powered by external power or EVAL board.”[/quote]

Can you please do one more test above, pls? We need only 4 wires for testing, remove some wires not necessary to keep them simple.

@ Dat

Dat,

right now, I have wired SCL, SDA, +5V, GND, RESET, SPI_SSEL, SPI_MOSI. I do not know how to set it up in I2C mode unless all these connections are made.

In my code, I initialize my port pins as I need them to be, then set the reset pin low while I configure the ALFAT by setting SPI_SSEL high and SPI_MOSI low. I then go configure my I2C module, bring the reset high, wait 100mS and read the banner. Once it has been successfully read, I send the card reader mode command, and look for its return value. After I receiver the !00<0x0A> I plug the cable into the USB port and get the unrecognizable balloon.

I can/will reduce this to the 4 wires you speak of, but I don’t know how it will get to the I2C mode.

Steve

PS. I am sure it is something I am doing because I have tried it with the ALFAT-OEM board and gotten the same problems. EVAL works, my host does not.

Something different…

This time around when testing it, it semi-worked. I have been watching the Universal Serial Bus controllers in my device hardware section. When plugging in the cable, It usually updates that section with unknown device. This last time it loaded a USB mass storage device but it had a yellow exclamation point on it and when I clicked on it a message popped up that said “device could not start”. I have not been able to repeat that condition.

When it is set to UNKNOWN DEVICE, and I click on the yellow exclamation point , the Device Status says…

This device is disabled because the firmware of the device did not give it the required resources. (Code 29)

I don’t know if this helps, just more info.

Steve

@ Bad Steve -

We don’t use MOSI and SSEL in I2C. You can connect them to GND and VCC from ALFAT board to setup I2C interface. Don’t need to release them because we don’t use it during testing.

The ALFAT must be in EVAL board, and there should be only 3 wires, SCL, SDA, GND connect to your host.

Let me know if this way work or not, please!

DAT

It did not work. 3 wires, gnd SCL, SDA. Power coming from eval board. Host reads banner, reads response. If I use other commands they work, i.e. read files from disk.

Steve

@ Bad Steve -

what we can help you now is, if you can ship your boards (host + ALFAT SDR) to us then we will try our best to help you find out what problem can be.

Dat,

What would this entail? What exactly would you need, firmware for the host? do you have microchip programming stuff? cabling for the programmer?
Steve