Please use the I2C discovery code to show the address. Again, look in the demo folder for the i2c discovery. Hook up a serial TTL converter between the 1937 and your Pic (If you dont have one, they are very very cheap and will provide huge amount of value when debugging).
Let me know the address displayed from the discovery program.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In preparation of the TTL converter arriving, you should take 16f1937 I2C discovery program and compile, then connect up the TX from the chip to your PC and connect the 0v! You will get nothing displayed on the terminal but if you add SCKP =1 to the GCB then you will!
SCKP sets Transmit Data Polarity and therefore for chips that support setting Transmit Data Polarity you do not need a TTL converter for transmitting. You still need a TTL converter for other chips and reasons.
The polarity of the transmit data can be controlled with the SCKP bit of the BAUDCON register. The default state of this bit is ‘0’ which selects high true transmit Idle and data bits. Setting the SCKP bit to ‘1’ will invert the transmit data resulting in low true Idle and data bits. The SCKP bit controls transmit data polarity in Asynchronous mode only. In Synchronous mode, the SCKP bit has a different function. See Section 25.4.1.2 of the datasheet.
So, you may be able to run the i2c discovery before your TTL converter arrives.
I did try the i2c discovery this morning. It works a treat.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My USB toTTL converter arrived today, Keith's must've got lost in the post :)
Im getting garbage on the terminal screen on the PC though. Am I doing it right?
InitSer 1, r1200, 1+WaitForStart, 8, 1, none, normal
In PuTTY I've set the following:
Baud rate 1200
Data bits 8
Stop bits 1
(no option for start bits)
Parity None
Flow control None
Edit: The 16F676 doesn't have a USART - but I didn't think one was needed for the software serial routines?
Edit2: Each time data comes through to the PC, only 10 (garbled) characters come up not the 11 + CR + LF that are being sent. I've tried a baud rate of 300 at both ends but no change.
I will keep investigating, but it seems to suggest I'm doing something fundamentally wrong with serial connections.
The PIC I'm using is an old one, and the calibration data has been lost so I'm wondering if that's the cause of the garbage (bad timing = incorrect baud). I will try again with a newer PIC or an external crystal.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I swapped the 16F676 for a 16F1825 which made it work. I'm assuming the internal oscilator in the 676 is out of calibration due to the missing calibration setting.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've just started putting together a troubleshooting guide (in the demos and guides). I'm going to do I2C next.
Still nothing on the display but I have a feeling that the Serial Display adapter may be at the cause om my problems.
On the rear of the adapter are three option links 'A0' 'A1' and 'A2' All three are open circuit.
Let us try to determine the address.
Please use the I2C discovery code to show the address. Again, look in the demo folder for the i2c discovery. Hook up a serial TTL converter between the 1937 and your Pic (If you dont have one, they are very very cheap and will provide huge amount of value when debugging).
Let me know the address displayed from the discovery program.
I don't have one of those beastie's in the armoury. is this what you mean?
http://www.ebay.co.uk/itm/RS232-TTL-Converter-Module-Board-Adapter-MAX3232-120kbps-3-5V-Serial-Port-TK-/231389780526?hash=item35dfe7da2e:g:7qkAAOSweW5VaQ8C
If so I'll have to put the project back on the shelf until it arrives next week. Bit confused about the modus opperndi ??
" between the 1937 and your Pic" Do you mean between the16F1937 and the Display Adapter ??
I use these - they have a DTR that is operational. http://www.ebay.co.uk/itm/1-2-5-10PCS-6Pin-USB-2-0-to-TTL-UART-Module-Converter-CP2102-STC-Replace-FT232-/272356900132?var=&hash=item3f69bc7d24Ⓜ️mRy2V32Z9uaSyxoxiK3h6KQ
Between... the 16f1937 and your PC. My error.
I have ordered one of these :
http://www.ebay.co.uk/itm/262448073893
The discription is very similar to yours with the difference being that it is here in the UK and it should be here on Tuesday.
'Between... the 16f1937 and your PC' - Mud just thickened a bit.....
In preparation of the TTL converter arriving, you should take 16f1937 I2C discovery program and compile, then connect up the TX from the chip to your PC and connect the 0v! You will get nothing displayed on the terminal but if you add SCKP =1 to the GCB then you will!
SCKP sets Transmit Data Polarity and therefore for chips that support setting Transmit Data Polarity you do not need a TTL converter for transmitting. You still need a TTL converter for other chips and reasons.
The polarity of the transmit data can be controlled with the SCKP bit of the BAUDCON register. The default state of this bit is ‘0’ which selects high true transmit Idle and data bits. Setting the SCKP bit to ‘1’ will invert the transmit data resulting in low true Idle and data bits. The SCKP bit controls transmit data polarity in Asynchronous mode only. In Synchronous mode, the SCKP bit has a different function. See Section 25.4.1.2 of the datasheet.
So, you may be able to run the i2c discovery before your TTL converter arrives.
I did try the i2c discovery this morning. It works a treat.
Results from my I2C discovery are:
My USB toTTL converter arrived today, Keith's must've got lost in the post :)
Im getting garbage on the terminal screen on the PC though. Am I doing it right?
InitSer 1, r1200, 1+WaitForStart, 8, 1, none, normal
In PuTTY I've set the following:
Baud rate 1200
Data bits 8
Stop bits 1
(no option for start bits)
Parity None
Flow control None
Edit: The 16F676 doesn't have a USART - but I didn't think one was needed for the software serial routines?
Edit2: Each time data comes through to the PC, only 10 (garbled) characters come up not the 11 + CR + LF that are being sent. I've tried a baud rate of 300 at both ends but no change.
Last edit: Peter 2016-09-27
Can you use the demo code ? The i2c discovery uses hardare serial and you will find this code is fully operational.
Sorry, being dim. Software. Ohh.
I just tested your code. Works ok here. I get lots of 'Hello World'.
My terminal is set to 1200.
I am not sure what the issue is.
I will keep investigating, but it seems to suggest I'm doing something fundamentally wrong with serial connections.
The PIC I'm using is an old one, and the calibration data has been lost so I'm wondering if that's the cause of the garbage (bad timing = incorrect baud). I will try again with a newer PIC or an external crystal.
That solved it:
What solved it?
I swapped the 16F676 for a 16F1825 which made it work. I'm assuming the internal oscilator in the 676 is out of calibration due to the missing calibration setting.