1 2 Previous Next 24 Replies Latest reply on May 23, 2017 3:38 PM by user_429602494

    PSOC 4 not getting i2c data and hangs from DS1307 RTC

    dgallatin95_1423736

      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
      http://www.element14.com/community/thread/25071/l/psoc-4-pioneer-kit-com...

         

      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

         

      Thanks

         

      (sorry if this may be a double post my first attempt doesn't post to the forum once I log out.

        • 1. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
          user_242978793

          Sir it would help if you added the pins for the I2C to the design.  Right now you only have UART pins on the design.

          • 2. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
            user_242978793

            Sir P4 (0) and P4(1) are used for the I2C port that is why they had the Serial ports at P3(7) and P0 (5)

            • 3. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
              user_242978793

              Here is your program give this a try. I do not have a DS1307 to try it with but it should work.  I have been using the PSOC RTC component not an external board.

              • 4. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                user_242978793

                Don't forget to jumper the UART pins to P12(6) and P12(7) so the serial data can get to the PSOC 5 chip.

                • 5. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                  dgallatin95_1423736
                          Hi bobgoar, thank you sir. I tried yours but no difference. Cant even tell what was chagned in any of the main files compared to my original. Though the files you sent, some do have a later time stamp. I did try P0.5 and 3.7. No difference. It prints the intial putstrings and chars but stops after it tries to get the time from the ds1307 I didn't see anywhere even in the examples to do pins in the design schematic for the I2c component. Thats why mine doesnt pins are jumpered i'm mainly trying this to see how i2c works and this was the simpliest I could find. My I2C LCD design wasn't working(Really its a MCP23008 breakoout board soldered to an 4x20 Char LCD, but that will be a different thread if I still can't get it to work)   
                  • 6. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                    user_1377889

                    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.

                       

                     

                       

                    Bob

                    • 7. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                      user_242978793

                      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 . 

                      • 8. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                        dgallatin95_1423736
                                Ok, I didn't realize in the file i uploaded that the pin assignments for I2C disappeared. Sorry about that. That was leading me to confusion in your response. I still can't get this to work I've got all physical connections done just like in that pic on project 35. I can print to the hyperterm screen before it starts processing the i2c commands I even tried as you suggested, just disbaling the SPI and doing a clean build. Though I stilll have to remove or commment out all the SPI function calls in main. Still doesnt' work. I decided to debug it to check those I2CMaster error status as Dana mentions above. It hangs when trying to access the RAMMEmory of byte 0 I2C_I2CMasterSendStart(I2C_ADDRESS, WRITE); returns errorr status number 2 which is SCB_I2C_MSTR_NOT_READY Though it still tries the next command I2C_I2CMasterWriteByte(RAM_LOCATION); Which is returning a NAK -(MSTR_ERR_LB_NAK Error condition: Last byte was NAKed.) and causing it to hang becasuse it is a blocking function. It won't continue becasue its not successful. I even pulled the SDA wire from the PSOC to the DS1307 and got the same thing. AS to the I2C clock, where do I change it? I don' see it as a setting in the component editor screen The regular clock component in the example is at 5% +-2 in the schemaic field Bu when I am looking at it in the clock tab of the cydwr file, I see for my uart proram, the example one and the one you sent back I see -100 +-2 for the I2C clock tolerance Where do I change the I2C clock tolerance ? No place to change that in the component   
                        • 9. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                          user_1377889

                          Set device IMO to 48MHz and use attached settings.

                             

                           

                             

                          Bob

                          • 10. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                            user_242978793

                            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.

                            • 11. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                              user_242978793

                              Dgallatin: You did supply the DS1307 board with 5 Volts and gnd from the Pioneer board. I am sending you the data sheet. 

                              • 12. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                                user_242978793

                                Here is the picture of the unit an the hookup.

                                • 13. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                                  dgallatin95_1423736

                                  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.

                                  • 14. Re: PSOC 4 not getting i2c data and hangs from DS1307 RTC
                                    user_1377889

                                    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.

                                       

                                     

                                       

                                    Bob

                                    1 2 Previous Next