Hi, this is a modification of Project 35 from element14 website. i took out the SPI component and code as I didn't need it and kept is as simple as possible
The wiring is the same except I used P0.4 and P0.5 for RX and tX as thats what the UART project and guide shows to use and it works. I don't know why project 35 uses different pins P0.5 and 3.7 to connect to 12.6 and 7
All other connections are the same for SDA, SCL , V5 and gnd pins as seen on webiste
Adafruit DS1307 breakout board and it does work with an arduino.
UART_UartPutChar and String do work up until the function to get the time from the RTC DS1307
Seems to hang on the GetTime Function that calls the I2C functions.
Will not display anything past that.
Its the same code for getting data from RTC as in project 35.
What am I missing?.
See attached bundle
(sorry if this may be a double post my first attempt doesn't post to the forum once I log out.
All I2CMaster functions return a status word which helps to interpret the cause of any errors, you just have to use the result.
Definitions for the bit-patterns are in the .h-files.
Dgallatin: What I was trying to say is that when you are working with PSOC you must make sure your external wires are attached to the correct port on the PSOC 4 pioneer kit. Your original program file didn't have any resources assigned to the the I2C component and that is what I corrected in the new file I sent you. If you let it PSOC Creator will assign the resources but it may not be on the pins your design needs so you have to open the Uart.cydwr file and change the resources to agree with your design pin outs. I also noticed the clock resources was different to the original Element 14 file. Your I2C clock has a -100 +2 % Tolerance this does not agree with the original design. If I was doing this design I would have just have right clicked on the SPI component in the topdesign.cysch and selected disable. Then do a clean build and it should remove the SPI parts from the design. I would have also left the UART component as is. Once I got it working then you can change the UART component .
Dgallatin: I have been doing some research on the DS1307 board and it is a 5 volt logic device. I also checked the #35 article on element 14 and clicked on the hookup picture and saw that the Voltage select jumper is set to 5 volts operation on the PSOC 4 pioneer kit. It doesn't stated that in the article to change the jumper. I would suggest that you change the jumper and try the program again and let us know the results.
Thank you gentleman. I have tried both the above. Changing the IMO 48mhz and the changed the data rate to 100 kbps in the I2C component . No help. I changed the jumper (Good catch!) and that didn't help.
What voltage is being changed on that for the jumper? Is that for the I2C bus line or the pin that is marked as supplyig 5V that I am connected to and did measure 5v from. I Even connected a LED and resistor to it to make sure it was supplying current
What I have noticed in the site wide manager for clocks where I changed the IMO to 48mhz, the clock spoeed for I2C is really high. 800 khz for 50 kbps or when I changed it to 100 kbps, it went to 1.6MHZ. No way to get that down to the max I2C clock speed of 100 Khz as per the DS1307 datasheet unless i use external clock terminal component connected to I2C(Whcih i tried) and that didn't work .
Also, the I2C Master tab on the I2c component has a voltage setting for the clock . But its greyed out at 3.3v: the default.
I wonder if thats the cause becasue the DS1307 breakout board has the 2.2K resistors tied 5V. Not 3.3v. Like to know why that can't be changed.
Regarding voltage setting grayed out: A look into the datasheet reveals
I2C bus voltage (V)
This option is only applicable for PSoC 4100 BLE/PSoC 4200 BLE/PSoC 4100M/PSoC 4200M devices. It specifies the voltage applied to the I2C pull up resistors when Slew rate is I2C FM+. The voltage no less than applied to I2C pulls up resistors must be provided by the VDDD supply input, otherwise the I2C pins cannot be placed. Valid values of VDDD are determined by the settings in the Design-Wide Resources System Editor (in the <project>.cydwr file). This range check is performed outside this dialog; the results appear in the Notice List window if the check fails. Default is 3.3 V.
The clock supplied to the I2C component is divided internally, in the datasheet are tables shown with legal clock and divider values.
Check your clock and data lines with a scope. When the I2C_MasterSendStart() returns an error there is (apart from a bad addressing) usually an electrical issue the cause.
Thank you sir.
That helped me determine that the PSOC doesn't like the DS1307 for some reason. I ran it and the led went red. So I connected up the I2C backpack that I have soldered to an LCD module. Changed the address to 20 and got a green led. OScope does show clock signal.
I had read that too in the data sheet, but found it confusing for the moment anyway.
So for some reason, my PSOC 4 doesn't like my DS1307, even though the ds1307 works fine connected to an arduino. I'll have to connect the PSOC to Arduino via I2C and make sure that works.
Dgallatin: I have ordered A DS1307 Clock module to see if I can get it to work with the code that was in the #35 Element 14 100 projects in 100 days and also your code. I should have it on Monday 8/31/2015. I wanted to compare how this module compares to the PSOC 4 RTC component so this will allow me to do that and also try to fix your issue. It is not the same as your module but should work for what we are trying to do. I am glad that you got the I2C test program to work. I was thinking that maybe we should be using the EzI2C component it may have worked better for this application.
Dgallatin: I just checked the shipping information and it will be here Tuesday instead of Monday. I'll keep you informed on how it goes when I get it.
Oh ok! I look forward to hearing what your results are!. Thank you sir.
I was in progress of doing my own module. I found several components that I already had to make my own. I just can't find the 32khz crystal to complete it. This way I cold try with and without the pull up resistors. An email thread I found here on the this forum had said that there were already built in SDA and SCL pull uprestistors but I havent confirmed that info yet.
Dgallatin: I received the DS1307 board and tried it out on the #35 Element 14 program. It works fine. It runs a little fast and the screen up dates are a little fast but it works. I then tried to use it on your program called Uart. I was unable to get the program to compile keep complaining about cy fit issues. I do not have the time to work on it as is. I plan to make a PSOC Pioneer program that is blank and insert you main.c and add the RTC.h files and see where that leads. I think your DS1307 board maybe the issue but I think it is your current program. I will let you know how it works.
dgallatin95_1423736 : I have some information and a working DS1307 Program for you. I discovered that the function call in your program where incorrect and it was also incorrect in the #35 program from Element 14 100 projects in 100 days. Here is the correct function call Get_time(); The Voids in the front and inside the brackets where incorrect.
Can someone at Cypress post a working version of I2C to External RTC.....thanks in advance.