6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 10, 2024 7:19 pm

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Sat May 28, 2016 8:00 pm 
Offline
User avatar

Joined: Mon May 04, 2015 10:55 am
Posts: 26
Location: UK
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 09, 2016 8:28 am 
Offline

Joined: Sun Dec 28, 2014 11:04 pm
Posts: 82
Location: Munich, Germany
DavidBuchanan wrote:
I came across this part on eBay recently.


... and ordered. Cool.
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 09, 2016 9:04 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10976
Location: England
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/


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 09, 2016 10:31 am 
Offline
User avatar

Joined: Mon May 04, 2015 10:55 am
Posts: 26
Location: UK
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.


Attachments:
image4198.png
image4198.png [ 529.92 KiB | Viewed 37176 times ]
Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 09, 2016 10:41 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
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.


Last edited by Tor on Thu Jun 09, 2016 11:03 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 09, 2016 11:00 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10976
Location: England
OK, I do like the sound of built-in FAT support!
http://www.dx.com/p/ch376-usb-communica ... ter-217605


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 09, 2016 12:26 pm 
Offline
User avatar

Joined: Mon May 04, 2015 10:55 am
Posts: 26
Location: UK
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:

Code:
#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'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.


Last edited by DavidBuchanan on Fri Jun 17, 2016 1:41 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 10, 2016 11:36 pm 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 589
Location: Michigan, USA
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


Attachments:
CH376DS1 Flash Controller Datasheet.zip [310.89 KiB]
Downloaded 438 times
Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 17, 2016 1:40 pm 
Offline
User avatar

Joined: Mon May 04, 2015 10:55 am
Posts: 26
Location: UK
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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 22, 2016 12:39 pm 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 589
Location: Michigan, USA
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


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 09, 2016 10:51 am 
Offline

Joined: Mon Jun 24, 2013 8:18 am
Posts: 83
Location: Italy
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

_________________
http://65xx.unet.bz/ - Hardware & Software 65XX family


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 14, 2017 3:28 pm 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 589
Location: Michigan, USA
Hi Marco.

Are you running the PIC18F2520 at 5 volts or at 3.3 volts?

Cheerful regards, Mike


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 21, 2017 9:55 am 
Offline

Joined: Mon Jun 24, 2013 8:18 am
Posts: 83
Location: Italy
Michael wrote:
Hi Marco.

Are you running the PIC18F2520 at 5 volts or at 3.3 volts?

Cheerful regards, Mike


Hi Mike,
PIC18F4520 run at 5V.

_________________
http://65xx.unet.bz/ - Hardware & Software 65XX family


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 21, 2017 2:11 pm 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 589
Location: Michigan, USA
Thank you, Marco. That's good news...


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 28, 2019 1:14 pm 
Offline

Joined: Sat Jun 04, 2016 10:22 pm
Posts: 483
Location: Australia
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: