6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 7:42 am

All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Sep 29, 2019 10:29 pm 
Offline

Joined: Wed Mar 20, 2019 7:14 pm
Posts: 28
Location: Rotterdam, The Netherlands
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!


Top
 Profile  
Reply with quote  
PostPosted: Mon May 22, 2023 6:40 pm 
Offline

Joined: Thu May 11, 2023 10:22 am
Posts: 3
Location: Belgium Poelkapelle (near Ypers)
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


Top
 Profile  
Reply with quote  
PostPosted: Mon May 22, 2023 8:07 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
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):
Attachment:
20230507_090018.jpg
20230507_090018.jpg [ 2.49 MiB | Viewed 2972 times ]

(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?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 05, 2023 6:51 pm 
Offline

Joined: Thu May 11, 2023 10:22 am
Posts: 3
Location: Belgium Poelkapelle (near Ypers)
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


Attachments:
usb ch376 uitleg.pdf [167.38 KiB]
Downloaded 110 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 11, 2023 3:00 am 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 255
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.
Thanks for mentioning this. I removed the 3.3V regulator and that seems to have resolved issues I was having with the chip locking up or returning garbage data. Now I just need to play around with it and figure out how to get it working. I'm using the parallel mode and have it wired directly to my bus.

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):
Attachment:
File comment: CH376S board with regulator bypassed
IMG_0658_v1.JPG
IMG_0658_v1.JPG [ 728.91 KiB | Viewed 2840 times ]


Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 25, 2023 7:48 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
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)


Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 25, 2023 8:22 pm 
Offline

Joined: Sun May 13, 2018 5:49 pm
Posts: 255
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.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jun 25, 2023 8:36 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 746
Location: Germany
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!


Attachments:
Module Test.zip [11.62 KiB]
Downloaded 95 times
Top
 Profile  
Reply with quote  
PostPosted: Fri Mar 08, 2024 2:47 pm 
Offline

Joined: Tue Feb 07, 2023 12:27 pm
Posts: 49
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.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 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: