CHUSBIE552

Showing posts with label Prototyping. Show all posts
Showing posts with label Prototyping. Show all posts

Sunday, 10 May 2020

Getting started with the CH55x Microcontroller

I have not been hiding the fact that I have love for the CH55x range of microcontrollers. So much so that I decided to stock several versions on the store. If you want to get hold of a few to experiment with check it out at Rabid's Electronics Emporium


I thought it's about time to write up a little tutorial on how to get up and running with this little unsung hero.

For this getting started tutorial I will be specifically looking at the CH552G but this tutorial will also apply for the CH551x, CH552x and CH554.



Installing the Toolchain 


This is not the only way to set up this toolchain there are other compilers and toolchains available, this, however, was the most straightforward way I found to get up and running.

First off the best thing to do is to install the compiler for this tutorial. We are going to use SDCC (Small Device C Compiler) this compiler runs natively in most linux flavours but if you're developing on a windows machine like I am then it will be worth setting up WLS (Windows Linux Subsystem) and installing Ubuntu.

Details on how to do that can be found here:
https://codebriefly.com/setup-windows-subsystem-linux-wsl-windows-10/

Once you are at the Linux command line SDCC can be installed with:

apt-get install sdcc build-essential

The next step will be to download the codebase for SDCC and the CH554 from GitHub:

git clone https://github.com/Blinkinlabs/ch554_sdcc.git 
Then navigate into the examples and compile them:

cd ch554_sdcc/examples/
make 
 If this completes correctly then your toolchain is setup.
You should have something similar to above.

After a little searching around, there is a way to setup SDCC in windows natively which can be found at the link below.

https://www.instructables.com/id/8051-C-development-using-FREE-compiler-SDCC/

As I mentioned I didn't use this method but if you feel a little more comfortable using it instead of installing WSL and Ubuntu it's worth a shot.

Preparing the hardware 

The MCU itself requires very little hardware to run in USB programming mode. Though a reasonable soldering skill is needed to solder the chip into a proto-board. There are many tutorials online on the best method to do this.

  
The above video is a very similar method to what I use. I am also considering stocking some already soldered on the store, as I will soon have the prototyping boards available.  


Once you have your board soldered and pins attached the rest of the circuit can be made up, on a breadboard. For me, I found the easiest way to attach the USB signal was to Butcher an old USB cable and solder Dupont jumper wire onto the exposed ends.


This has been really handy while I have experimented with this MCU.

The rest of the supporting circuitry can be made up, on a breadboard all it requires is 2 x 100nF ceramic capacitors between 3v3 and GND and between VCC and GND as down below.


If the chip is new and fresh from the factory then from my experience it drops straight into bootloader mode no a widows PC it makes the always familiar USB device sound :).

Of course, if this doesn't happen then the MCU will need to be set into bootloader mode.

Putting the MCU into USB Bootloader mode


There are two possible bootloader pins ton the CH552 the default from the factory is on P3.6. To active the bootloader the pin must be pulled to 3V3 briefly after reset. This can, however, be very problematic as the same pin is shared with USB DP. So for my purposes, I like to set up the bootloader pin as the available alternative which is P1.5 there is a catch though this pin ins needed to be pulled to GND.


Writing Firmware to the MCU 

First of all, you will need to download and install WCHISPTool this is the official and poorly translated to English tools from WCH themselves. 

This can be downloaded from here: http://www.wch.cn/products/CH552.html

Oddly enough the English WCH site doesn't give you any of the download links to the tools of datasheets so you will have to go through the Chinese site. 


once the software is installed and running it will look much like the above. You will need to select the '8-Bit CH55x series' tab and select the CH552 as you devise then all being well your device should appear in the device list below. 

 This tool gives you a few configuration options like:
  • Disabling the reset pin 
  • Enabling slow reset
  • Erasing the data flash 
  • Swapping the bootloader pin to P1.5
From my own experience swapping the bootloader pin is worth doing for me it helps getting it into bootloaders mode as P3.6 (the default pin) is shared with USB Data + which cam make things awkward. Where you have P1.5 tied to GND was very helpful for me as the MCU then automatically goes into USB bootloader mode every time it is reset or powered. 

To test the function everything is well if you select the user firmware you would like to use I used blink which but this point should be in the toolchain examples.

\ch554_sdcc\examples\blink\blink.bin
This will need to be selected as your 'User file' the click on Download(D) all being well you will have some lovely green text in the download record below saying the process was successful.

All being well if you hook and LED and resistor between pin P1.7 and GND then you will have a lovely blinky LED.



Starting your own application

This is very simple from mine I copied one of the examples and I started to edit form and just use the make command to compile it.

After a bit of trail and error managed to make it run LPD8806 strips of LEDs.


Messy but works :D


What I would like to do now is to add a USB CDC driver so I am able to adjust the colours over USB.

I have a both the CH552G and CH552T which has more IO are listed on my Tindie store.

Further Info on the CH552 can be found here:

datasheet(translated) https://github.com/rabid-inventor/document-archive/blob/master/datasheets/WCH/MCUs/CH552%20Datasheet_C111367.zh-CN.en.pdf

Improved Pinout table https://github.com/rabid-inventor/document-archive/blob/master/datasheets/WCH/MCUs/CH552-Pinout-details.csv





Saturday, 18 July 2015

Dirty Circuits Done Dirt Cheap


Often design and research is and expensive business, especially when dealing with technology that your are unfamiliar with. A big proportion of this is PCB manufacture and I have spend a few years looking for a low cost reliable method for PCB production.

The most cost effective method is to have the boards produced overseas but then you won't be sure of the quality of the boards until they return. This is where Dirty PCB step in.

Dirty has been setup by the guys at Dangerous Prototypes as a reliable access to PCB fabs overseas.











I discovered Dirty PCB while looking at another PCB manufacturers reviews and recommendation on a forum post.

So went over to there website and I was almost knocked of my feet at how cheap 2 layer PCBs were.


If you can keep your design under 5cm x 5cm and don't mind if you end up with anywhere between 8 - 12 PCBs then it is only $14 (9GBP) that could be less than 0.10GBP   1GBP per PCB. WOW! There is also a selection of colours for the solder masks at no extra cost.

For me that is great for me as most of my designs are under this size as 50x50mm is quite equate for a breakout board but for $11 more you can have up to 10cm x 10cm (100x100mm That's huge). 

There are a few things that you need to accept to get this price level the boards can only be 2 layers and the pad finish will be HASL (Hot Air Solder Leveling) there is an option for ENIG (Electro-less Nickel Immersion Gold) but it is $15 more. Also there free postage option is quite slow so its worth paying $19 more to get DHL airmail, I realise this is more that the PCBs cost but otherwise it could be a up to 8 weeks delivery. 

Next thing to have a look at is there capabilities, this is all listed in the FAQ.

Capabilities
ITEMCAPABILITY
MaterialFR-4 0.6mm-2.0mm 1oz copper ('standard' PCB material is 1.6mm thick, but we default to 1.2mm)
Layer number2L
Maximum size100*100mm (10*10cm)
ShapeAlmost anything! We'll send it and see if they accept it!
Min internal slot32mil (0.8mm)
Min core thickness4mil 0.08mm
Min core thickness16-96mil(inner) 16-118mil(out)
Min w/s5/5mil(I/L)
Min w/s5/5mil(O/L)
Min silkscreen line0.15mm
Min BGA sizeOblong:10*13.5mil/circle:12mil
Min SMD width8mil
Min solder dam3mil(green)/3.5mil(black)
Min dielectric thickness2.5mil
Min diameter of finished hole12mil
Tolerance of drill position+/- 2mil
Tolerance of finished hole sizePTH +/- 3mil
Tolerance of finished hole sizeNPTH: +/- 2mil
PTH hole copper thickness0.6~1.4mil
Max A.R of PTH8:1
Surface copper thickness1oz
Routing dimension tolerance(Z0) Impedance control 4mil
V-cutNow refused! 80*80mm(min) 380*300(max)
(Z0) Impedance control+/- 15%
Ionic contamination< 6.4ugNaCl/inch2
Surface treating(No PB) hot air levelling/AuSn/AgCN/Electrogilding/Ni/OSP*/G.F
*OSPOrganic solder-ability Preservatives
This is much the same as most board houses standard service I'm mainly looking at the trace thickness and clearance which is 4 thou (thousandths of an inch, this is a bit of a legacy thing with board houses) and a clearance of 5 thou.

There is some helpful things further down the page, Dirty PCB supply a design rules check file for Eagle this file is use in you design rules check to make sure your PCB design is manufacturable. They also supply a cam processing file to help export your design manufacture file. But if you use Eagle like I do you can just send in your .brd design file and Dirty PCB will do all the exporting for you. This is great as I don't have to worry about getting the export wrong or sending the wrong layer files.  

So that's it time to give them a spin. Note: Dirty PCB only accept PayPal payments best to make sure you PayPal details are upto date.

On thing I noticed after putting in my order is that the level of communication is amazing are reassuring, and you can also check the status of you order in the websites status page.  

One Week Later (seriously that is really really fast!)


Such Box! Much Cute! 


There is no mistaking this box the end stamp is very cool.


And then you even get a sticker, I like stickers :)


The PCBs where well wrapped but a little loose in the bag the could rub against each other possibly scratch the finish but this didn't happen in my case. 


I always get excited to see one of my own designs as PCB please don't get too excited this is not a product its just a demo board to try out a BLE chip that I might use in a product ;)


The finish is great the Silkscreen is legible and the resist is nice and even. lets have a look under the microscope.


The quality is excellent and precise the soldermask is tight to the pads with none of the ground fill exposed. The thing that really knock me off my feet is they have also managed to apply the mash between the the pads on the main package, these gaps are less than 0.2mm in width that is brilliant.

  
 And for the free sticker.


Got the perfect place for that.

So what do I think of Dirty PCB here is my round up:

  • Easy of use: Straight forward and quite fun the site feels as though it doesn't take itself to seriously and approachable. Though more payment options would be a nice addition.
  • Communication: Reassuringly comprehensive without feeling like I'm being spammed.
  • Lead Time: Quick! 
  • Packaging: Exciting!
  • Finish and Quality: Astounding good.
I can only award Dirty PCBs up to 5 sparks but in may opinion they deserve 6. Very pleased with the service.