CH375B USB Mass Storage Controller
- DavidBuchanan
- Posts: 26
- Joined: 04 May 2015
- Location: UK
CH375B USB Mass Storage Controller
I came across this part on eBay recently.
It is very cheap (~£2), and lets you interface with USB mass storage devices over an 8-bit parallel bus (it also has some serial modes).
I'm still waiting for mine to be delivered, but it looks like a very cheap and simple way to add storage to a project. When it eventially arrives, I'll hopefully post some sample code for interfacing with it.
The only downside is that the documentation is rather poor, but there are a few arduino libraries I could take a look at to figure things out.
It is very cheap (~£2), and lets you interface with USB mass storage devices over an 8-bit parallel bus (it also has some serial modes).
I'm still waiting for mine to be delivered, but it looks like a very cheap and simple way to add storage to a project. When it eventially arrives, I'll hopefully post some sample code for interfacing with it.
The only downside is that the documentation is rather poor, but there are a few arduino libraries I could take a look at to figure things out.
-
ArnoldLayne
- Posts: 109
- Joined: 28 Dec 2014
- Location: Munich, Germany
- Contact:
Re: CH375B USB Mass Storage Controller
DavidBuchanan wrote:
I came across this part on eBay recently.
Icing on the cake would be if it could handle USB HID devices like keyboards and mice. But for that price, I'm gonna find that out myself.
Re: CH375B USB Mass Storage Controller
I'll be interested to hear about how you get on with this! It does seem the CH375 chip can act as USB device or USB host. It seems to offer support up to block transfer level, so if you need filesystem support you'd do that in software. A couple of links:
http://www.8bit.8u.cz/Files/CH375/CH375DS1.pdf
http://www.electrodragon.com/product/ch ... mmunicate/
http://www.8bit.8u.cz/Files/CH375/CH375DS1.pdf
http://www.electrodragon.com/product/ch ... mmunicate/
- DavidBuchanan
- Posts: 26
- Joined: 04 May 2015
- Location: UK
Re: CH375B USB Mass Storage Controller
Mine has just arrived, so I'm going to start testing.
It has an undocumented header on it, which I've determined out the pinout for (See attachment).
It has a serial mode, which I'll use to figure out how the protocol works.
It has an undocumented header on it, which I've determined out the pinout for (See attachment).
It has a serial mode, which I'll use to figure out how the protocol works.
Re: CH375B USB Mass Storage Controller
I just got a couple of those in the door. I haven't had the chance to test anything yet. I also have on order a couple of the CH376 variant, which has built-in (FAT) filesystem support but is otherwise quite similar. Thanks for the picture with the pinouts!
Update: That pinout doesn't look entirely correct.. check this link: ftp://imall.iteadstudio.com/Modules/IM1 ... 009001.pdf
That header seems to be where you select serial/parallel mode.
Update: That pinout doesn't look entirely correct.. check this link: ftp://imall.iteadstudio.com/Modules/IM1 ... 009001.pdf
That header seems to be where you select serial/parallel mode.
Last edited by Tor on Thu Jun 09, 2016 11:03 am, edited 2 times in total.
Re: CH375B USB Mass Storage Controller
OK, I do like the sound of built-in FAT support!
http://www.dx.com/p/ch376-usb-communica ... ter-217605
http://www.dx.com/p/ch376-usb-communica ... ter-217605
- DavidBuchanan
- Posts: 26
- Joined: 04 May 2015
- Location: UK
Re: CH375B USB Mass Storage Controller
Oh dear, I seem to have bricked mine already. I had it working with my Arduino, and the GET_IC_VER command was returning a sensible value. I connected the INT pin to one of my Arduino pins before I had configured it as an input, and now the data lines are stuck at 0xFF.
Here's the arduino code I have so far:
I'm running it in parallel mode, with D2-D7 on the chip going to Arduino pins D2-D7, and D0-D1 on the chip going to Arduino pins D8-D9. The rest of the pins are specified in the #define statements.
I guess I'll have to order a CH376 now.
RE the pinout - I think my pinout is still correct, the TXD pin doubles as a switch between Serial and Parallel modes.
Here's the arduino code I have so far:
Code: Select all
#define COMMAND true
#define DATA false
#define READ A0
#define WRITE A1
#define INTERRUPT A2
#define Ad0 B00000100
#define d27 B11111100
#define d01 B00000011
#define GET_IC_VER 0x01
#define RESET_ALL 0x05
#define CHECK_EXIST 0x06
void awaitInterrupt() {
}
void portWrite(byte data, bool mode) {
DDRD |= d27;
DDRB |= d01;
PORTD = data & d27;
PORTB = data & d01;
setMode(mode);
digitalWrite(WRITE, LOW);
digitalWrite(WRITE, HIGH);
}
void setMode(bool mode) {
if (mode == COMMAND) {
PORTB = PINB | Ad0;
} else {
PORTB = PINB & ~Ad0;
}
}
byte portRead(bool mode) {
DDRD &= ~d27;
DDRB &= ~d01;
setMode(mode);
digitalWrite(READ, LOW);
byte output = 0;
output |= PIND & d27;
output |= PINB & d01;
digitalWrite(READ, HIGH);
return output;
}
void setup() {
Serial.begin(115200);
//pinMode(INTERRUPT, INPUT);
pinMode(READ, OUTPUT);
pinMode(WRITE, OUTPUT);
digitalWrite(READ, HIGH);
digitalWrite(WRITE, HIGH);
DDRB |= Ad0;
portWrite(RESET_ALL, COMMAND);
delay(50);
portWrite(GET_IC_VER, COMMAND);
Serial.print("Device ID: ");
Serial.println(portRead(DATA), HEX);
portWrite(CHECK_EXIST, COMMAND);
portWrite(~0x42, DATA);
Serial.print("Check: ");
Serial.println(portRead(DATA), HEX);
}
void loop() {
// put your main code here, to run repeatedly:
}I guess I'll have to order a CH376 now.
RE the pinout - I think my pinout is still correct, the TXD pin doubles as a switch between Serial and Parallel modes.
Last edited by DavidBuchanan on Fri Jun 17, 2016 1:41 pm, edited 1 time in total.
Re: CH375B USB Mass Storage Controller
Hi David and gang:
Sorry to hear you may have bricked it. Ouch!
I just ordered a couple of these CH376S modules last month (23-May) after stumbling across this article. They arrived Wednesday (08-Jun) but I haven't had a chance to hook them up yet.
Please let us know how it's going and if I make any progress I will do the same, Sir.
Cheerful regards, Mike
Sorry to hear you may have bricked it. Ouch!
I just ordered a couple of these CH376S modules last month (23-May) after stumbling across this article. They arrived Wednesday (08-Jun) but I haven't had a chance to hook them up yet.
Please let us know how it's going and if I make any progress I will do the same, Sir.
Cheerful regards, Mike
- Attachments
-
- CH376DS1 Flash Controller Datasheet.zip
- (310.89 KiB) Downloaded 645 times
- DavidBuchanan
- Posts: 26
- Joined: 04 May 2015
- Location: UK
Re: CH375B USB Mass Storage Controller
My CH376S arrived today.
To my dismay, my arduino circuit still did not work after swapping out the new part. It turned out to be a silly programming mistake! (I forgot to set the A0 input accordingly.) I have updated the code I posted previously.
Update: I now have my arduino reading files with the 376. Time to transfer to 6502!
Update 2: Using completely non-optimised arduino code, I was able to read an entire 64K file in under 1 second, which is very reasonable.
To my dismay, my arduino circuit still did not work after swapping out the new part. It turned out to be a silly programming mistake! (I forgot to set the A0 input accordingly.) I have updated the code I posted previously.
Update: I now have my arduino reading files with the 376. Time to transfer to 6502!
Update 2: Using completely non-optimised arduino code, I was able to read an entire 64K file in under 1 second, which is very reasonable.
Re: CH375B USB Mass Storage Controller
Happy to hear you didn't brick the CH375 module after all, David.
Gosh, reading 64kB per second on the parallel interface sounds great. I wonder what kind of speed you might expect using the serial interface? Perhaps ~10kB per second at 115,200 baud? Of course the Arduino is running at ~16-MIPS so I'm not sure we could expect that kind of speed with a 65C02/65C816 host.
Have fun.
Cheerful regards, Mike
Gosh, reading 64kB per second on the parallel interface sounds great. I wonder what kind of speed you might expect using the serial interface? Perhaps ~10kB per second at 115,200 baud? Of course the Arduino is running at ~16-MIPS so I'm not sure we could expect that kind of speed with a 65C02/65C816 host.
Have fun.
Cheerful regards, Mike
Re: CH375B USB Mass Storage Controller
I have one module CH375 so tried a little test interfacing this module with a PIC18F4520 (parallel interface).
On my test i handle a mouse, a keyboard and a flash disk.
Details and source code for the little application are here: http://65xx.unet.bz/ch375.txt
This sample show needs task for handle an usb device with CH375 in host mode:
- detect device plug/unplug
- get device descriptor and configuration descriptor
- get string descriptor
- a very simple descriptors parser
- automatic handling of 3 devices: mouse, keyboard, flash disk
- handling interrupt endpoint for mouse and keyboard
I choose PIC because is easy to interface with CH375 and because i can debug application with an ICD3 debugger.
In future i plan to interface CH375 with my 65C816 machine.
Note that flash disk handling is limited to read/write Sector(s), so file system managment is demanded to external firmware/software.
And one final note: documentation about CH375 is very poor, some commands are not explained and some don't work as expected.
Marco
On my test i handle a mouse, a keyboard and a flash disk.
Details and source code for the little application are here: http://65xx.unet.bz/ch375.txt
This sample show needs task for handle an usb device with CH375 in host mode:
- detect device plug/unplug
- get device descriptor and configuration descriptor
- get string descriptor
- a very simple descriptors parser
- automatic handling of 3 devices: mouse, keyboard, flash disk
- handling interrupt endpoint for mouse and keyboard
I choose PIC because is easy to interface with CH375 and because i can debug application with an ICD3 debugger.
In future i plan to interface CH375 with my 65C816 machine.
Note that flash disk handling is limited to read/write Sector(s), so file system managment is demanded to external firmware/software.
And one final note: documentation about CH375 is very poor, some commands are not explained and some don't work as expected.
Marco
http://65xx.unet.bz/ - Hardware & Software 65XX family
Re: CH375B USB Mass Storage Controller
Hi Marco.
Are you running the PIC18F2520 at 5 volts or at 3.3 volts?
Cheerful regards, Mike
Are you running the PIC18F2520 at 5 volts or at 3.3 volts?
Cheerful regards, Mike
Re: CH375B USB Mass Storage Controller
Michael wrote:
Hi Marco.
Are you running the PIC18F2520 at 5 volts or at 3.3 volts?
Cheerful regards, Mike
Are you running the PIC18F2520 at 5 volts or at 3.3 volts?
Cheerful regards, Mike
PIC18F4520 run at 5V.
http://65xx.unet.bz/ - Hardware & Software 65XX family
Re: CH375B USB Mass Storage Controller
Thank you, Marco. That's good news...
-
DerTrueForce
- Posts: 483
- Joined: 04 Jun 2016
- Location: Australia
Re: CH375B USB Mass Storage Controller
I got one of these recently, and I've noticed a bit of a data point. On the S and P_S headers, the two pins that are marked as no-connect in the images above are connected together, and apparently to nothing else. I've probed most of the connections on my board(mainly the ones connecting to ICs, rather than the passives), and there is no apparent connection. I've also run the Arduino test program linked to above using that connection, and it seems to work.
I'm not sure why they did this, as the only reason I can think of is to make switching between parallel and serial interfaces easier, but that's almost totally pointless when one can just remove a jumper on a 3-pin header. It does make sense, given that the header the jumper came on is labelled P_S, though. P for parallel, S for serial, and the positions correspond to where you'd put the header for each.
I think I'll end up using a parallel interface through a VIA, or make up an adapter to SPI-10, so I can use interrupts. Once it's put into USB Host mode, it sends a byte when I insert or remove a USB stick, and that makes writing a serial driver a bit hard, because the UART I'm using has buffers, and that extra byte would sit in there until a driver routine got called. When it did, things would go off the rails fairly quickly due to misinterpreted bytes.
I think that if the USB module can raise an interrupt, then I can probably handle it much more easily, because I can then know to look for it.
I'm not sure why they did this, as the only reason I can think of is to make switching between parallel and serial interfaces easier, but that's almost totally pointless when one can just remove a jumper on a 3-pin header. It does make sense, given that the header the jumper came on is labelled P_S, though. P for parallel, S for serial, and the positions correspond to where you'd put the header for each.
I think I'll end up using a parallel interface through a VIA, or make up an adapter to SPI-10, so I can use interrupts. Once it's put into USB Host mode, it sends a byte when I insert or remove a USB stick, and that makes writing a serial driver a bit hard, because the UART I'm using has buffers, and that extra byte would sit in there until a driver routine got called. When it did, things would go off the rails fairly quickly due to misinterpreted bytes.
I think that if the USB module can raise an interrupt, then I can probably handle it much more easily, because I can then know to look for it.