Any advice/pointers or instructions would be most helpful. I am still a newbie at embedded design so please humor me.
I have a datalogger module written using an Atmel 8051. I want to add a USB port to it so I can simply plug in a USB flash drive and have the data automatically downloaded as a formatted text file.
I have read
formatting link
but I still don't know where to start. If someone could point me to an online resource or a book... preferrably something with similiar applications... that'd be great!
Here's a few of my questions.
If I buy a USB controller such as those provided by Micrel or Cypress... do I still need to write a "Host Controller Driver?"
What parts of the USB protocol do I need to implement, and how much of it is already implemented by the USB controller and the USB Flash Drive.
Do I really need to worry about all that protocol timing stuff ... shouldn't the USB controller take care of that for me?
Assuming that I get the answer to the three questions above, how do I write a TEXT file to a USB flash drive? I know how to do it if I was writing a windows app... but this is different. Anyone have any idea?
Any advice/pointers or instructions would be most helpful. I am still a newbie at embedded design so please humor me.
I have a datalogger module written using an Atmel 8051. I want to add a USB port to it so I can simply plug in a USB flash drive and have the data automatically downloaded as a formatted text file.
I have read
formatting link
but I still don't know where to start. If someone could point me to an online resource or a book... preferrably something with similiar applications... that'd be great!
Here's a few of my questions.
If I buy a USB controller such as those provided by Micrel or Cypress... do I still need to write a "Host Controller Driver?"
What parts of the USB protocol do I need to implement, and how much of it is already implemented by the USB controller and the USB Flash Drive.
Do I really need to worry about all that protocol timing stuff ... shouldn't the USB controller take care of that for me?
Assuming that I get the answer to the three questions above, how do I write a TEXT file to a USB flash drive? I know how to do it if I was writing a windows app... but this is different. Anyone have any idea?
You don't want to do this. Use a removable flash storage medium like SD.
Implementing host-side USB is not a trivial exercise and should only be undertaken for the gravest reasons, and where no reasonable alternative exists.
Ok, so I don't want to do this with a USB port. So... umm... how would I go about using a removable flash storage medium like an SD card or an CF card? Would I just embedd a card reader into my current module?
Where can I go to find more information about this?
If you have SPI then SD and MMC are fairly simple - you can bit bang it if you have to. Lewin's (larwe) DosFS is perfectly adequate as a file system for the SD card too.
I used an MMC card datasheet and a google for how FAT16 worked to write my own drivers from scratch and it wasn't hard - and I don't have much experience in that area.
At least one of the flash card protocols includes the ability to communicate with the card over SPI, so you don't tie up a bunch of processor pins. A recent Circuit Cellar had an article on doing just this -- it would be in the May-July time frame, probably.
The bottom line is that a FAT-12 or FAT-16 file system is pretty easy to implement, and talking to the card isn't hard either.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Posting from Google? See http://cfaj.freeshell.org/google/
"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
You would just embed a socket into your current module and add the software to talk to it. There are zillions of example circuits and software for various micros floating about the web.
Note that you must interface between 3.3V and 5V, if your system is 5V.
For the filesystem layer, as another respondent suggested, you can use my (free) DOSFS .
I don't know what you mean by identifying what you have -- I thought you had some design requirements to which you wanted to fit hardware.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Posting from Google? See http://cfaj.freeshell.org/google/
"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
Just a suggestion: use AT43USB380 USB Host from Atmel. It has USB library to handle all USB host transactions and MSD (FAT32) library to handle USB Disk.
More impressed than when you find out how long he has to pay you do to it from scratch. The Viniculum device is an absolute bargain, and unless your volume is well into
But it's complexity that's already been developed and, more importantly, tested. I have no doubt that there are subtle quirks with different USB memory devices - if you buy the solution from someone selling it to lots of people, there is a good chance that they will already have found most of the bugs.
Why exactly..? Who cares what's inside the chip as long as it does the job. Actually it's an 8 bit core with some hardware to help accelerate 32 bit operations.
My point is that if the question is "How do I remove data from point A and collect it at point B?" there are much simpler options - and if it comes to that, better-tested ones (through having been fielded longer).
Has anyone actually gotten one of these things to work?? I'm trying t read a USB flash drive using the VDIP( Vinculum w/ VDAP firmware) throug a UART port on an MSP430F1611.
The code below is supposed to generate an interupt to when CTS#(reference from the uP) is asserted. The interupt asserts RTS#, and waits for th character to come into the RX Buffer. The character is then stored int memory. The code is also supposed to transmit a to the VDIP, thi would generate a response saying that a USB devices is or in no connected.
The there are two problems I have noticed so far. For transmitting character to the VDIP, I assert the RTS# and wait for CTS# to be asserted Before sending a character to the VDIP over the UART. However CTS# neve goes high. The second problem is that nothing is ever recieved from th VDIP because CTS# never goes high. And so nothingis ever transmited o received.
The code that I'm to use to communicate with the VDIP is shown below.
;---------------------------------------------------------------------------- ; Initialization Sequence #include ORG 01100h RESET mov.w #0A00h,SP Initialize stackpointer StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL ; Sto WDT bis.b #001h, &P1DIR ; Use P1. as output bic.b #001h, &P1OUT bis.b #030h, &P3SEL ; Use P3.4,5 for UART0 bis.b #050h, &P3DIR ; Use P3.4,6 as output bis.b #040h, &P5DIR ; Use P5.6 for DREQ bis.b #040h, &P5OUT ; mov.b #004h, &BCSCTL1 ; Setup Clocks mov.b #088h, &BCSCTL2 ; mov.b #002h, &IFG1 ; SetOsc0 bic.b #OFIFG, &IFG1 ; Test Oscilator mov.w #0FFh, R15 ; SetOsc1 dec.w R15 ; jnz SetOsc1 ; bit.b #OFIFG, &IFG1 ; jnz SetOsc0 ; mov.b #021h, &U0TCTL ; Setup U0TCTL mov.b #008h, &U0RCTL ; Setup U0RCTL mov.b #baudDiv0, U0BR0 ; Setup Baud Rate Clock mov.b #baudDiv1, U0BR1 ; mov.b #baudMod, U0MCTL ; bis.b #0C0h, &ME1 ; Enable UART Transmitters mov.b #010h, &U0CTL ; UART0 Released mov.b #000h, &P1IES ; Port 1: Low=>High Transitio Cause Interupts bic.b #0FFh, &P1IFG ; Clea any existing Port 1 Interupt Flags mov.b #002h, &P1IE ; Allo P1.1 to Cause Interupts bis.b #GIE, R2 ; Enable global interupts ;---------------------------------------------------------------------------- ; Super_Loop mov.w &fromUSB, R5 ; R5 is pointer to a table where data is received from the UART
Super_Loop mov.w &toUSB, R4 ; R4 is pointe to data being sent to UART call #UART0_TX ; transmi character subroutine
bic.b #rts,&P1OUT ; Reset P1.1 (RTS# on uP, CTS# on Host)
reti ; return from interupt ;--------------------------------------------------------------------------- ; Memory toUSB DW testDataTx ; pointer to table where data is transmitted
fromUSB DW testDataRx ; pointer to table where data is received
testDataTx DW 00Dh ; Data to be transmitted to USB testDataRx DW 0, 0, 0, 0, 0, 0, 0, 0 ; Data received from USB Host
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.