Good day all. I have a project where on my board I have to PIC 18F2680 running at 20Mhz and 12F683 running a 8Mhz.
Using the example posted on the learning center I am trying to bit bang RS232 between the 2 devices. I have done this before using 18F2680 running at 20Mhz and 16F690 running at 19.6Mhz with great success. I tried to communicate at 2400bps then 300 bps. The values I am sending are 0x01 to 03. I'm only communicating in one direction, 18F2680 to 12F683. Based on some test I have done using an LED, and an If block with "if dataRX is less then 255" I know that data is being receive. But response to "if dataRX is 0x01" produces no results. Is there something in particular that I might be missing when trying to link these 2 devices together. Note I am using the same bit time for both.
Ondra
PIC to PIC bit bang communication
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC to PIC bit bang communication
Hello Ondra
If you are using the internal oscillator on the 12F683 then this may be slightly off which is causing the communication to receive eg a 3 or a 0 instead of the sent 1.
I would play around with the bit delays on one of the devices (probably the 12F683) until you reach a value that receives the data correctly.
You must also ensure that the software receive is allowed to run as often as possible to make sure that the start bit is not missed. Eg if your baud rate is 4800bps then you will need to check the bus at least every 208us (1 / 4800).
Lowering the baud rate eg increasing the bit delays should help to make the comms more reliable between the two devices.
If you are using the internal oscillator on the 12F683 then this may be slightly off which is causing the communication to receive eg a 3 or a 0 instead of the sent 1.
I would play around with the bit delays on one of the devices (probably the 12F683) until you reach a value that receives the data correctly.
You must also ensure that the software receive is allowed to run as often as possible to make sure that the start bit is not missed. Eg if your baud rate is 4800bps then you will need to check the bus at least every 208us (1 / 4800).
Lowering the baud rate eg increasing the bit delays should help to make the comms more reliable between the two devices.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel