Part 2 Connecting and Using BvSerial
This applies to ALL ByPic devices. It shows how to connect your device and use BvSerial which is an essential part of the communication with ByPic.
Connecting to the Serial Device
There are lots of different kinds of serial device and most will suffice. The only criteria is that they should do the following.
- Put out 3.3V and/or 5V DC
- Have a TX and RX line that operates on TTL levels, i.e. 0 and +5V or 0 and 3.3V levels.
- Optional but very convenient, have a DTR output << This provides a convenient reset
This device meets the criteria and so will many other imported USB to serial devices. Note that you cannot use the COM port of a PC directly as this outputs 12V levels. Use the DuPont connectors to connect the serial device to the serial connector on the ByPic.
|USB to Serial Pin||PCB Pin Name||DIL 28 pin IC MX1 Pin Number|
|+5V||+V||Do Not Use 5V on IC**|
|DTR *||DTR to Reset||(see breadboard circuit)|
* This is optional and not required for the device to work. The purpose is to provide a reset for the board. If it is not available on your USB to Serial, then a short length of wire connected to that pin and momentarily touched to the ground pin will reset the device.This is optional but will provide a convenient reset from BvSerial (BVS)
** If you have a PCB then there is a 3.3V regulator built in, so the 5V output of the USB to Serial should be used. If 5V is used directly on the IC it will damage it.
Observe that the TX and RX are crossed although in some USB to Serial devices the TX has been an input and RX an output so it is not always the case.
You can just follow the colours of the wire in this example. There will never be a 1:1 match of pins as there are so many different types of USB to Serial and even within those types they change on a regular basis.
TIP: Once connected properly, glue a small piece of plastic over the top of the connectors so that they will stay in position after disconnecting. This saves having to trace each individual connector each time you connect up.
There is some more information about serial devices here.
This section applies only DIL type ByPic chips that do not have a PCB,If you have a PCB then skip down to 'Start Up'.No soldering is needed and very few components to have a fully working microcontroller, follow the instructions below.
The circuit diagram shows the connections that need to be made for a minimal system, although it will work without the DTR connection this is an incredibly useful way of resetting the device when using BV_COM2. It is advisable to have a decoupling capacitor as close to the chip as possible. This is shown as a 0.1uF device on pin 28.
The decoupling capacitor is to reduce noise and if this is to go into your own project at least one is needed and two would not go amiss.
The 10uF capacitor on pin 20 is necessary (4.7uF will also work), the device will not work without it as it provides the smoothing for the internal voltage regulator.
In case you were wondering, no crystal is required as the chip has an on board 8MHz oscillator that has its frequency increased by way of a (PLL) Phased Locked Loop to 40MHz which is the operating frequency of the processor.
This circuit is used throughout, that is all that is needed to have a fully fledged 32 bit microcontroller up and running. In the diagram it is assumed that the chip is powered by the serial device.
Once wired up and reset (although it will reset by itself on power up) the TX line (pin 21) will send the sign-on message to the serial device at 115200 Baud. If you have the USB to serial wired up and BV_COM running then you will see the sign on message. If not see the trouble shooting section later on in the text.
Doing the Wiring
Experienced constructors can skip this. If you have the kit, provided with it is a long breadboard. Observing static precautions insert the IC somewhere in the middle. The legs are normally splayed out so they will need pressing against a flat surface to push them in a bit on both sides.
Ordinary telephone wire is used to wire the board and this is the thick white wire, use the cutters to remove all of the white sleeving to reveal the coloured wires inside. On later kits, although not as neat but much quicker special wire is provided that has a pin on either end.
It helps to choose an orange colour for the +3.3V and green for ground but really makes no difference to the way it works. The wires can be cut to exact length and, as we will be using this board for a few projects it makes sense to be as neat as possible.
Wire the board according to the diagram. The USB – Serial converter will provide the 3.3V power supply that is needed.
Here is just one example of how the breadboard could be wired. A word of warning here, the strips down each side of the board that are useful for carrying power are NOT continuous and need a link every so often, you can see the link at the top right of the picture.
Special points to note:
- On the IC pin 1 has a dot next to it – see the kit list
- Normally TX on the USB goes to RX on the IC and vice-versa
- The + end on the capacitor (kit item J) goes to pin 20
- There are two +3.3V connections and three ground connections
It is useful to use the strips down the side as + and ground, these have been coloured with a felt tip pen.
* There is one exception to the TX,RX, one of the devices supplied had this marked backwards so that in fact TX was input and RX was output. This was known as the type 3 device, there will be a paper note about this in the devices bag.
If you are uncertain, simply swap them over, no harm is done of they are on the wrong pins.
When installed and plugged in a new COM port will be created by the system. Use this port to communicate with the IC via BvSerial. Connecting to the breadboard is done via the DuPont connecting wire, some kits are conveniently supplied with Male - Female type wires where the female end plugs into the USB to serial and the mail end plugs into the breadboard.
If you are asked for a driver then get it from the ByVac documentation site. The part will be a BV103, BV104 or BV105
The current reset arrangement will work in most circumstances but is not ideal. The main advantage is that it will react to a change in DTR rather than an absolute DTR level. So if the DTR is high and it goes low, this will cause a reset. If the DTR is low and goes high this will cause a reset.
An alternative reset circuit that may be a bit more reliable is shown above. This is for information so that it may be used (or not) on a final project. It does however mean that the DTR normal state must be high and to reset it must be taken low then high again. The DTR can also be replaced with a push button to ground if required.
For a stand alone system simply connect the reset pin to a 10K resistor to +3V3
You will need a terminal emulator. Two emulators are available, BV_COMM and BvSerial, the latter is the one we are going to use as it has an editor that will come in handy. Also as BvSerial (BVS) is written in Python it can be used on Linux systems as well.
Use the above BvSerial link to install BvSerial - it is very easy to do.
It is assumed that BvSerial is installed, connect the ByPic device to the serial port and start BvSerial, you should see something like this.
Anything typed here will go to the ByPic device. A dot '.' as the first character of a line is the start of a command so provided the DTR line is connected .r will reset the device. If there is no communication with the ByPic device then check out the troubleshooting guide below.
Provided you have checked the wiring and made sure that 3.3V has not been exceeded* the only complication is the serial connection. Here are some pointers:
* Applies to IC only as PCB's work on 5V
- Check that you are using the correct COM ports. There may be several on the system, refresh the ports by typing .port and selecting the correct one, unplug the USB to serial, refresh the ports again and see which one is missing.
- Check that the TX (pin 21) goes to the RX of the serial device, if not sure swap them round. No harm will be done if they are the wrong way round. Type 3 in fact is TX to TX and RX to RX so swap them round anyway just to try it. Reset should bring up the sign-on screen.
- Establish that the USB to serial is working with BVS by connecting TX to RX and typing something in to BVS, what you type in should be echoed back.
- It is possible that one of the leads belonging to the USB to Serial is open circuit, check them.
- Uninstall and re-install the CP210x drivers, particularly if 3 above doesn't work.
- (Applies to breadboard only)Is the Vcap in place, on the right pin and the right way round (+ end goes to pin 20)
- (Applies to breadboard only)Is there 2 power connections and 3 ground connections - check.
- Check the Baud rate, stop bits and data bits are correct, 115200, 1 or 2, 8.
- If the USB to serial and BVS are working as 3 above; use the alternate reset circuit and replace DTR with a push button to ground – or a bit of wire that can be momentarily connected to ground. Connecting to ground causes a reset at which point data will come out of pin 21. You will be able to see this if you have the RX pin on the USB to serial connected to the TX pin on the IC.
- (Applies to breadboard only) If no data is coming out then the wiring is incorrect, is the chip the correct way round? Pin 1 is next to the dot and notch on the IC. Are all three ground connections in place? Are both power connections in place? Check Vcap again, is it the correct way round.
- If you can receive data but not send it then try re-installing the driver for the USB to serial device. Type 1 is particularly prone to this if you have had a previous driver for some other device installed.
- If data is coming out but nothing appears on the terminal then check the Baud rate is set to 115200 also make sure any hardware handshaking is turned OFF this will prevent any information from getting through, reinstall the com port drives again.
- (Applies to breadboard only) If the voltage has been exceeded or the supply has been connected the wrong way round then the IC will be destroyed. Note that all IC's are programmed and checked before shipping and so a faulty IC will not have been supplied. If you suspect this has happened then return the IC for checking.
- (Applies to breadboard only) It is all about confidence, keep trying and you will get it going eventually, check and double check. It is a simple circuit but any single error will cause it not to work. Most of all assume that the IC is okay and it is your wiring or set up that is wrong. If you assume that the IC is faulty then just give up now as you will never get it working.