Closed shadeyinka closed 6 years ago
first important part from the example: https://github.com/felis/UHS30/blob/master/libraries/UHS_FS/examples/USB_HOST_SHIELD/UHS_FS_NEW_DEMO/UHS_FS_NEW_DEMO.ino#L1
In other words you need to know the label on the target volume. No label defaults to "/", AKA root part of the filesystem tree.
UHS30's filesystem automatically will mount upon initial detection, and there is a way to know when that event happens. See here: https://github.com/felis/UHS30/blob/master/libraries/UHS_FS/examples/USB_HOST_SHIELD/UHS_FS_NEW_DEMO/UHS_FS_NEW_DEMO.ino#L273
After that point, you are free to read/write as needed. Just do not forget to close all files, and sync the filesystem when all writes are done. You do not need to unmount it, that happens automatically as well once you remove or power down the target storage.
Thanks a lot. My problem wit UHS30 had been that code execution does not go beyond while(KINETIS_Usb.Init(1000) != 0); the Aduino ADK just sits hear endlessly. Is there something i am doing wrong. I use Arduino 1.6.8, Arduino AVR Board manager 1.6.11, Mega ADK Arduino, Windows 7. Thanks a lot
Sounds to me like a pin conflict, or I don't have something right for supporting the particular board. I don't own one of these boards, so I can only make a guess that it is indeed a conflict. If the SDcard library uses SPI, this indeed could be the case, especially if it does not use transactions. Can you tell me which SDcard library you are using?
For now, the problem is with the UHS30 example files. Even without the SD card shield, the code hangs when executing the line
while(KINETIS_Usb.Init(1000) != 0);
UHS20 example testusbHostFAT.into works on my board. I don't know why UHS30 examples will not work.
Could it be the cs_pin for the max3421 chip? On my board, max3421 seems to be on pin 10, the SD card shield is on pin 8
Ok, that is fine, what are the MISO/MOSI/CLK line pin numbers?
It uses the standard ICSP pins on Arduino mega
Ok, did you connect 9 to pin 3 with a jumper wire? https://github.com/felis/UHS30#avr-arduino
I did. Nothing happened
Do you know where the INT pin from the MAX3421E is routed? Connect that to pin 3, and it should wake up and work. UHS30 uses interrupts and does all the work in the background, which means no polling...
I don't know where the INT pin of max3421 is, however, I will find out and do what you suggested.
I also noticed that the UHS20 with the examples from your github page didn't work either. I found one (probably modified) that ended up working. I will upload it to you in a few minutes. The difference might show something
Try the following:
Connect pin 54 to pin 3
then... specify the SS/INT pins like so...
MAX3421E_HOST MAX3421E(53, 3); // SS on pin 53, IRQ on pin 3
...if that works, I'll place this fix in the library
I will check it out and give you a feedback if it works. Meanwhile, the link to the UHS2 that worked on my board is presented here:
@xxxajk please see how I have done it in UHS2.0: https://github.com/felis/USB_Host_Shield_2.0/blob/ff8bdb24c19f254aa0496d3933920f3ae92f85a0/avrpins.h#L31-L32, https://github.com/felis/USB_Host_Shield_2.0/blob/ff8bdb24c19f254aa0496d3933920f3ae92f85a0/avrpins.h#L514-L517, https://github.com/felis/USB_Host_Shield_2.0/blob/ff8bdb24c19f254aa0496d3933920f3ae92f85a0/UsbCore.h#L37, and https://github.com/felis/USB_Host_Shield_2.0/blob/ff8bdb24c19f254aa0496d3933920f3ae92f85a0/usbhost.h#L158-L162.
@Lauszus difference--- UHS30 needs an actual real IRQ pin....
Thanks so much. I will check it out. However in your previous post
I guess you meant, "Connect pin 53 to pin 3" and not "Connect pin 54 to pin 3". Pin 54 & Pin 55 are GND in Aduino Mega
If this is a regular Arduino mega with a USB host shield, then the jump from 9 to 3 should work. The ADK isn't the same thing and those pins are in a different location.
I think I found out something on the Aduino Mega ADK for use as USB Host
The MAX3421E communicate with Arduino with the SPI bus. So it uses the following pins: Digital: 7 (RST), 50 (MISO), 51 (MOSI), 52 (SCK)
Digital pin 7 should not be used as input or output because is used in the communication with MAX3421E
There are three Connections to the MAX3421E through Non broken out on Headers: PJ3 (GP_MAX), Pin66 on ATMEGA 2560 PJ6 (INT_MAX), Pin69,pin8 on ATMEGA 2560 PH7 (SS). Pin27 on ATMEGA 2560 Pin53 on Arduino ADK Header
http://www.electroschematics.com/7965/arduino-mega-adk-pinout/
54 in line 84 should be referenced to PJ6 (since it has no broken out header, I don't know how to properly label it). *I could be wrong about this Sir
Pin 54 on Aduino Mega and ADK is GND http://download.arduino.org/products/MEGAADK/arduino-mega-adk-schematic.pdf
Thanks
Hi, In USB_Host_Shield_2.0: avrpins.h P54 and P55 (line 514-517) were properly defined. I am not sure of whether it was so done in UHS30
Sorry for my troubling. Here is my Board https://www.aliexpress.com/store/product/MEGA-ADK-2560-R3-Enhanced-version-Swith-for-I-O-5V-3-3V-USB-CH340G-USB/1950989_32672086405.html?spm=2114.12010608.0.0.2995e5c0nS6V2R
You will need to locate where the INT_MAX pin is, and connect it to pin 3. The MEGA ADK has different pin numbers than the regular MEGA. What I see in your picture is basically a MEGA2560 with the MAX3421E on-board.
Do they provide a schematic? Perhaps you need to compile for plain MEGA2560?
FYI the official Arduino Mega ADK is totally different from this board too.
Any chance on donating one to me so i can figure it out?
The working code is: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Libraries/_06_Microduino_USBHOST_MAX3421E
Thanks
Definitions seem to be identical, I'll see what I can find out as far as the actual tie points for these pins.
#ifdef BOARD_MEGA_ADK // These pins are not broken out on the Arduino ADK
#define P54 Pe6 // INT on Arduino ADK
#define P55 Pj2 // MAX_RESET on Arduino ADK
#endif
Looks like you will have to find a good place to tap in on these two wires.
Are you capable of doing fine soldering?
P54 I mean, not the reset one :-)
Looks like this is actually a valid /INT pin!
Thanks. I will check out the Board for the possibility of tapping PE6 and PJ2. I am not sure I can do fine soldering though but I am willing to givebit a try.
Is there no way round UHS20 for the working code code, while solution is being sought for the ADK board?
Thanks
Well, there are two options to get this to work without soldering. 1: make a new set of read/write/mode for the digital pins. OR 2: fix the definitions for the ADK in the Arduino definitions....
I think the first one makes the most sense at this point, and is very easy to do.
Which of the libraries need to be tweeked to Making a new set of read/write/mode for the digital pins in the library and How do you suggest it be implemented. (I wouldn't mind going by this as a first option before having a permanent and generic solution to the problem-at least to have a working project). The problem looks so simple, yet daunting.
I assume it is more difficult to get the UHS20 move data between SD card and USB FlashDrive.
Easier to work around in UHS30, UHS2 is horrible for this. Working on the patch for you to test, it seems to only be half broken :-)
I just got the schematic to the Arduino Mega ADK board by Robotdyn. I will send it now through my mail.
Please send to my personal email, available off of my own github page. Just click my Avatar :-)
Here is the Schematic for the Mega ADK. I just got it from the suppliers.
On 18 Aug 2017 9:17 am, "Andrew Kroll" notifications@github.com wrote:
Easier to work around in UHS30, UHS2 is horrible for this. Working on the patch for you to test, it seems to only be half broken :-)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/felis/UHS30/issues/32#issuecomment-323290734, or mute the thread https://github.com/notifications/unsubscribe-auth/AMFadA8KQw0vgWckmwttHuCP2WGtU4l9ks5sZUh8gaJpZM4O5EQM .
Send to my personal email as an attachment please.
Thanks in anticipation for the patch. A million cheers to you if it works.
Thanks
On your board, which of the following resistors are populated (IF THESE ARE MARKED!) R11 R12 R13 R16
I hope you can confirm this from the schematic MAX3421E. ATMEGA2560. ADUINO ADK RST_3V3 PH4/PJ2. PIN7 SCK_3V3. PB1. PIN52 SS_3V3. PB0. PIN53 MOSI_3V3. PB2. PIN51 MISO_3V3. PB3. PIN50 GPC_3V3. PH5/PJ3. PIN10 INT_3V3. PH6/PE6. PIN9
If this is true, an easy work around should be possible
Sorry. This is gabbled up. The formating was messed up. I will send it through my mail again
I just resent it as an *.rtf attachment.
All the resistors mentioned are marked
Try now...
What about the following changes
In USB_HOST_SHIELD.h 81 #elif defined(BOARD_MEGA_ADK) 82 #define UHS_MAX3421ESS 53 83 #define UHS_MAX3421EINT 9 //modified from 54 to 9
In what other files can one rectify this?
Leave it as 54
Sorry, I checked a wrong Board. None of the components were labelled.
Not a problem. Does the new code work?
I havent seen the New Code. Did you send it to my mail or you uploaded it to your github page?
I hope you have confirmed this from the schematic. They look normal and INT can be taken fro Pin9, I dont know why it is not working MAX3421E............... ATMEGA2560............... ADUINO ADK RST_3V3 __PH4/PJ2.__PIN7 SCK_3V3__PB1___PIN52 SS_3V3PB0___PIN53 MOSI_3V3PB2___PIN51 MISO_3V3PB3_____PIN50 GPC_3V3PH5/PJ3__PIN10 INT_3V3___PH6/PE6__PIN9
I reverted back line 83 to #define UHS_MAX3421EINT 54
Do a pull from github :-)
Ok. I will feed you back as soon as I test it. Thanks
no problem :-)
I am building a datalogger whose primary memory is the SD card and the secondary storage is the USB flash drive. The data in the SD card is downloaded into the USB flash drive like once a week. I am using Arduino Mega ADK with Max3421 USB host chip.
Any example code will do, especially to be able to initialize and mount the SD card and write/read text files. CS on my SD card shield is on digital pin 8 (cs_pin=8) of my Arduino board.