cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4 MCU

Anonymous
Not applicable

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.

0 Likes
Reply
24 Replies
Honored Contributor II

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.

0 Likes
Reply
Honored Contributor II

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)

0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Anonymous
Not applicable
        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)   
0 Likes
Reply
Esteemed Contributor II

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

0 Likes
Reply
Honored Contributor II

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 . 

0 Likes
Reply
Anonymous
Not applicable
        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   
0 Likes
Reply
Esteemed Contributor II

Set device IMO to 48MHz and use attached settings.

   

 

   

Bob

0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Honored Contributor II

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

0 Likes
Reply
Honored Contributor II

Here is the picture of the unit an the hookup.

0 Likes
Reply
Anonymous
Not applicable

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.

0 Likes
Reply
Esteemed Contributor II

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

0 Likes
Reply
Honored Contributor II

Try out this I2C test program I set the address for the slave to 0x68 if that is wrong you can change it in the header.h. Program is supose to check out the I2C.

0 Likes
Reply
Anonymous
Not applicable

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.

   

Thank you.

0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Anonymous
Not applicable

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.

0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Anonymous
Not applicable
        Hi bobgoar, yes sir it appears to be that board. I built my own ds1307 board after ffinally inding a spare 32khz crystal last night. I ran your test program and it showed green led. I ran the #35 program as is, no changes and it reads the clock. Though it only constantly reads the same time of 00:00:80. At least its progresss. Not sure what is up with the adafruit ds1307 breakout board. seems to work fine on an arduino. Thanks for the help!   
0 Likes
Reply
Honored Contributor II

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.

0 Likes
Reply
Anonymous
Not applicable
        Hi bobgoar, thank you sir ! Sorrry,for late response,I haven't checked back here in abit. It does update now. I had wondered if it was that function call,but wasn't surewhat it should be. Thanks again.   
0 Likes
Reply
Anonymous
Not applicable

Can someone at Cypress post a working version of I2C to External RTC.....thanks in advance.

0 Likes
Reply