So, did anyone get the CH376 module to work on a 65(C)02 system?
And would you care to share your code?
I am really struggling with getting this module to work, Especially the file opening/reading/writing/directory listing stuff, all very confusing...
A little bit of working example code would be much appreciated!
CH375B USB Mass Storage Controller
-
jaccodewijs
- Posts: 29
- Joined: 20 Mar 2019
- Location: Rotterdam, The Netherlands
-
aragnatarion
- Posts: 3
- Joined: 11 May 2023
- Location: Belgium Poelkapelle (near Ypers)
- Contact:
Re: CH375B USB Mass Storage Controller
I am trying te ch 376, i have connected it to my acorn atom 6502
6502 d0 to d7 > ch d0 to d7
a0 > a0
BC38 > cs
r!w > wr
0v > rd
> rst active high
nc > int
gnd > 0v
5v > 5v
so the data on adres BC38 and command on BC39
testing communication via command = 06 ; data=A5 returns data =5A (dataout is inverse of data in)
I am testing inBASIC ,disc capacity works but sometimes a second command fails.
grts
Erwin
6502 d0 to d7 > ch d0 to d7
a0 > a0
BC38 > cs
r!w > wr
0v > rd
> rst active high
nc > int
gnd > 0v
5v > 5v
so the data on adres BC38 and command on BC39
testing communication via command = 06 ; data=A5 returns data =5A (dataout is inverse of data in)
I am testing inBASIC ,disc capacity works but sometimes a second command fails.
grts
Erwin
Re: CH375B USB Mass Storage Controller
oh sweet i didn't know this thread existed already.
i've been using the CH376 with my 65816 SBC and it's been working perfectly fine (still making a C library for the chip). though i'm using the SPI interface instead of the parallel one, as that takes up less IO on my VIA. especially useful since i also have an RTC on the same SPI lines.
here the module i made that contains both the CH376 and the MCP795 RTC (battery holder on the back): (ignore the botch wires, i already fixed that in v2, and once i confirmed the RTC works i'll upload all files to my github)
anyways, aragnatarion.
if you're using one of those arduino CH376 modules, they're running at 3.3V which may cause occasional issues when reading from the chip. you can modify the module to run directly with 5V by simply removing the regulator and bridging the left and middle pins of where the regulator used to be. also i'd recommend making use of the INT line, i find it much more convenient than polling the BUSY bit in the status register.
besides that and your wiring being potentially unstable/loose, i don't know what else would cause commands to not work sometimes. have you tried setting up a loop and just repeating a command until it works?
i've been using the CH376 with my 65816 SBC and it's been working perfectly fine (still making a C library for the chip). though i'm using the SPI interface instead of the parallel one, as that takes up less IO on my VIA. especially useful since i also have an RTC on the same SPI lines.
here the module i made that contains both the CH376 and the MCP795 RTC (battery holder on the back): (ignore the botch wires, i already fixed that in v2, and once i confirmed the RTC works i'll upload all files to my github)
anyways, aragnatarion.
if you're using one of those arduino CH376 modules, they're running at 3.3V which may cause occasional issues when reading from the chip. you can modify the module to run directly with 5V by simply removing the regulator and bridging the left and middle pins of where the regulator used to be. also i'd recommend making use of the INT line, i find it much more convenient than polling the BUSY bit in the status register.
besides that and your wiring being potentially unstable/loose, i don't know what else would cause commands to not work sometimes. have you tried setting up a loop and just repeating a command until it works?
-
aragnatarion
- Posts: 3
- Joined: 11 May 2023
- Location: Belgium Poelkapelle (near Ypers)
- Contact:
Re: CH375B USB Mass Storage Controller
I got the ch376 from aliexpress they seem to work on 5 V,
I want to try it on an old computer Acorn Atom 6502 (a challenge)
I can reset, test the communication, I can get the information on the root dir files (32 bytes) per dir or file.
The "chines english" documentation needs a lot of good will and imagination to get an understanding about the commands.
reading files is still a mysterie.
Lucky I find things on this site and via via on other sites that help me.
attached is a listing as screenshots as information.
greets and thx
I want to try it on an old computer Acorn Atom 6502 (a challenge)
I can reset, test the communication, I can get the information on the root dir files (32 bytes) per dir or file.
The "chines english" documentation needs a lot of good will and imagination to get an understanding about the commands.
reading files is still a mysterie.
Lucky I find things on this site and via via on other sites that help me.
attached is a listing as screenshots as information.
greets and thx
- Attachments
-
- usb ch376 uitleg.pdf
- (167.38 KiB) Downloaded 197 times
Re: CH375B USB Mass Storage Controller
Proxy wrote:
if you're using one of those arduino CH376 modules, they're running at 3.3V which may cause occasional issues when reading from the chip. you can modify the module to run directly with 5V by simply removing the regulator and bridging the left and middle pins of where the regulator used to be.
There are multiple variations of the CH376S board out there. I checked out the voltages on mine and, sure enough, VCC (pin 28) was running off a 3.3V regulator. More interestingly, V3 (pin 9) had a cap on it, but was not tied to VCC, which the datasheet says it should be for VCC=3.3V operation. The "just a cap on it" configuration is only for 5V VCC. This means the board came in a configuration that is not valid, according to the datasheet - it says that pin 9 should be tied to VCC when running the chip off 3.3V and should just have a cap to ground on it when VCC=5V.
I believe the V3 pin is an internal regulator that makes around 3V for the USB data lines (USB 2.0 power is 5V, but the data line signals run around 3 or 3.3V). When running with 3.3V VCC there wouldn't be enough voltage after the internal regulator so, when running off 3.3V for VCC, they recommend tying 3.3V directly to V3 as well (esentially bypassing the internal regulator).
For others thinking of bypassing the regulator, double check that VCC (pin28) is NOT shorted to V3 (pin 9) on your PCB. Looking at screen shots of other boards, it's hard to tell but it appears they are shorted on at least some variations of the board. For 5V operation, the V3 pin (pin 9) should only have a cap to ground on it and should NOT be tied directly to VCC (pin 28).
Here's a photo of my modified board (U2 removed and two of its pins shorted to tie VCC to 5V):
Re: CH375B USB Mass Storage Controller
glad i was able to help, it is truely strange why it would run at 3.3V by default, and not even correctly according to the datasheet.
they could've atleast included a jumper to manually set the supply voltage....
anyways, just as info i have confirmed the RTC on my custom made module works. so as promised i uploaded everything to github:
https://github.com/ProxyPlayerHD/USB-RTC_Module
(and yes those KiCad files already have the fixed version, so no botches needed)
they could've atleast included a jumper to manually set the supply voltage....
anyways, just as info i have confirmed the RTC on my custom made module works. so as promised i uploaded everything to github:
https://github.com/ProxyPlayerHD/USB-RTC_Module
(and yes those KiCad files already have the fixed version, so no botches needed)
Re: CH375B USB Mass Storage Controller
Oh, That's great! Do you have your source code that talks to the device somewhere that I could look at? It looks like you are using one of the serial connections while I'm using the parallel interface, but I think I'm just having issues getting the commands sent in the correct order.
Re: CH375B USB Mass Storage Controller
yea the RTC uses SPI so it made sense to use SPI for the CH376S as well.
plus i just prefer that interface over parallel since it's unidirectional and takes less than half the amount of IO pins on my VIA.
All of the code i used to test the chip with is written entirely in C. most of the RTC code was... "borrowed" from some Linux kernel or utility i found online that had support for the same chip. the CH376S code was based off an arduino library, but i rewrote most of that to be more like stdio's file functions.
you should be able to adapt it to your system, though replacing the SPI functions with parallel ones will take a bit of effort.
"SBC.h" contains constants specific to my system, though only the SPI pin assignments are really required.
"MemAccess.h" is just useful to have, it contains bit manipulation and memory accessing macros.
"BFIO.h/.c", are the main program files and stand for "Basic File IO".
hope it's of some use!
plus i just prefer that interface over parallel since it's unidirectional and takes less than half the amount of IO pins on my VIA.
All of the code i used to test the chip with is written entirely in C. most of the RTC code was... "borrowed" from some Linux kernel or utility i found online that had support for the same chip. the CH376S code was based off an arduino library, but i rewrote most of that to be more like stdio's file functions.
you should be able to adapt it to your system, though replacing the SPI functions with parallel ones will take a bit of effort.
"SBC.h" contains constants specific to my system, though only the SPI pin assignments are really required.
"MemAccess.h" is just useful to have, it contains bit manipulation and memory accessing macros.
"BFIO.h/.c", are the main program files and stand for "Basic File IO".
hope it's of some use!
- Attachments
-
- Module Test.zip
- (11.62 KiB) Downloaded 189 times
Re: CH375B USB Mass Storage Controller
An error has occurred in the CH376S. I can read the files, but if the file contains a $E6 value, for some reason the CH376 skip the byte and in the output instead of the $E6 value is the next byte of data. This happens whenever a byte in the file has the value $E6. I wrote to the manufacturer and am waiting for a response.
I'm using parallel mode. I don't know if this problem occurs in a serial connection.
I'm using parallel mode. I don't know if this problem occurs in a serial connection.
Re: CH375B USB Mass Storage Controller
Has anyone had any luck getting this chip to work in parallel mode connected to a 6522 VAI?
Last edited by java6502 on Fri May 30, 2025 9:10 am, edited 3 times in total.
Re: CH375B USB Mass Storage Controller
So after consulting the datasheet some more, it turns out I was not following the timing diagram correctly. After making a few corrections, everything seems to work now.