element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Cypress Kits
  • Products
  • Dev Tools
  • Cypress Kits
  • More
  • Cancel
Cypress Kits
Forum Add pull-up resistor to I2C pins ??
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Cypress Kits to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 3 replies
  • Answers 2 answers
  • Subscribers 24 subscribers
  • Views 2690 views
  • Users 0 members are here
  • cy8ckit-042
  • cy8ckit-044_pioneer_kit
Related

Add pull-up resistor to I2C pins ??

ducthangee61
ducthangee61 over 5 years ago

Hello everyone !

 

 

I'm a new user to the CY8CKIT-042CY8CKIT-042. I'm trying to communicate this kit with a sensor via I2C protocol. To do this, I've connected the SDA and SCL pins of the sensor to the pin P4.0 and P4.1 of the CY8CKIT-042CY8CKIT-042. The next thing I need to do is configurate these pins P4.0 and P4.1 to a pull-up resistor to drive the SDA and SCL line.

 

 

I'm trying to do this in the PsOc Creator Software but I don't know how. Can anyone help me with this.

 

 

Thanks

  • Sign in to reply
  • Cancel

Top Replies

  • BigG
    BigG over 5 years ago +6 suggested
    I'm assuming you wish to use internal pullups. To learn how to configure those, go to the I2C block in your "TopDesign" page and open up the datasheet. This provides you with all the info you need. Find…
  • ducthangee61
    ducthangee61 over 5 years ago in reply to BigG +2
    Thanks for helping me out !!! Now I'm having problems with the coding part. I'm trying to read the data using CY8CKIT-042 CY8CKIT-042 from the sensor via I2C, so I'm using the I2C component in the kit…
  • BigG
    BigG over 5 years ago in reply to ducthangee61 +1 suggested
    I suggest two things. 1. Read through the " I2C APIs " section in the datasheet as this provides a very handy reference of all the functions available for use. There is a very handy summary table, which…
Parents
  • BigG
    0 BigG over 5 years ago

    I'm assuming you wish to use internal pullups.

     

    To learn how to configure those, go to the I2C block in your "TopDesign" page and open up the datasheet. This provides you with all the info you need.

     

    image

     

    Find table 1, as this summarises configuring the pins.

     

    image

    Then to configure internal pullups just find the "Internal Pullups" section in the datasheet.

     

    Within this section it basically tells you to...

     

    Add the following code before starting the Component (with SCB_Start()) - don't forget to change "SCB" part to match same name as your I2C block. In my case my block name was simply "I2C".

     

    /* Change SCL and SDA pins drive mode to Resistive Pull Up */
    SCB_scl_SetDriveMode(SCB_scl_DM_RES_UP);
    SCB_sda_SetDriveMode(SCB_sda_DM_RES_UP);

     

    (also don't forget to check that the "slew rate" properly matches clock speed as this caused problems with me once before).

     

    Hope that helps.

    • Cancel
    • Vote Up +6 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • ducthangee61
    0 ducthangee61 over 5 years ago in reply to BigG

    Thanks for helping me out !!!

     

    Now I'm having problems with the coding part. I'm trying to read the data using CY8CKIT-042CY8CKIT-042 from the sensor via I2C, so I'm using the I2C component in the kit as the master device (because the pull-up pins send the start condition)

    image

     

    Do you know if there is any code examples to read the I2C from the outside sensor ?? I can only find the code examples which demonstrates the I2C communication between the PsOc 4 and PsOc 5LP on the kit (https://www.element14.com/community/message/75946/l/psoc-4-pioneer-kit-community-project05-usb-i2c-utility#75946 )

     

    And I also don't know how to verify the I2c transmission has succeeded or not. Is there any register or any software to see the I2C data transmission.

     

    If you know how, please help me out with these problems. Thanks. 

     

     

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • ducthangee61
    0 ducthangee61 over 5 years ago in reply to BigG

    Thanks for helping me out !!!

     

    Now I'm having problems with the coding part. I'm trying to read the data using CY8CKIT-042CY8CKIT-042 from the sensor via I2C, so I'm using the I2C component in the kit as the master device (because the pull-up pins send the start condition)

    image

     

    Do you know if there is any code examples to read the I2C from the outside sensor ?? I can only find the code examples which demonstrates the I2C communication between the PsOc 4 and PsOc 5LP on the kit (https://www.element14.com/community/message/75946/l/psoc-4-pioneer-kit-community-project05-usb-i2c-utility#75946 )

     

    And I also don't know how to verify the I2c transmission has succeeded or not. Is there any register or any software to see the I2C data transmission.

     

    If you know how, please help me out with these problems. Thanks. 

     

     

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • BigG
    0 BigG over 5 years ago in reply to ducthangee61

    I suggest two things.

     

    1. Read through the "I2C APIs" section in the datasheet as this provides a very handy reference of all the functions available for use. There is a very handy summary table, which provides both the "Slave" and "Master" functions (in that order). As you want to read data from a sensor there are two functions:

     

    SCB_I2CMasterReadBuf();
    SCB_I2CMasterReadByte();

     

    2. Then to understand how to use these functions, I found that the three I2C master examples provided in PSoC Creator (via the "Find Code Example..." option on the start page and then choosing PSoC 4200 as "Device Family") were sufficient to get me started. These were:

    • I2C_Master_High_Level - this example uses the Read Buffer method
    • I2C_Master_Low_Level - this example uses the Read Byte method
    • I2C_SCB_Master - this example uses the Read Buffer method

     

    When you download these examples, it will also download a PDF document, which explains what these examples do. I found the first two example documentation to be pretty good. The 3rd one (I2C_SCB_Master) was not that helpful in explaining the I2C code.

     

    Besides documentation, the last example is probably the easier one to get started (IMO) as all the code is in the main.c file.

     

    Note, that in my experience, I sometimes found that the sensor documentation and associated I2C methods to get the sensor data may require you to use the low level functionality. But suggest just starting with the high level methods first, as simpler.

     

    Hope that helps.

     

    PS. check through above examples as they also demonstrate how to check that transmission completed etc.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube