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
Dev Tools
  • Products
  • More
Dev Tools
Forum Issue reading a pin state on the PSoC 4200
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Dev Tools to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 4 replies
  • Answers 1 answer
  • Subscribers 76 subscribers
  • Views 1828 views
  • Users 0 members are here
  • micro controller
  • read digital
  • psoc4
  • dircuit issue
  • issue
  • digital input
  • cypress psoc 4200
  • psoc creator
  • input pin
  • switch
  • cy8ckit49-42xx
Related

Issue reading a pin state on the PSoC 4200

balearicdynamics
balearicdynamics over 8 years ago

Hi to all! I am using the CY8CKIT-049-42xxCY8CKIT-049-42xx PSoC board from Cypress to control two stepper motors. This controller will be replicated a number of times in a modular system. The main design of the circuit schematics in the PSoC Creator 3.3 is shown in the image below:

image

The stepper controller part needs 4 PWM due the characteristics of the controller. Then I need to set two end-switches for the steppers and two signal LEDs. These are set as shown in the figure above. The I2C connection instead is not yet present.

After an incredible number of tries I continue to be unable to get any signal from the input switches  END_STOP_1 and END_STOP_2. To make the things easy I have created a second project excluding all but the switches and the LEDS, attached to this post.

 

I have tried in several ways the kind of pin input settings with no result at all. The main code uses pin read function as in the code snippet below and the pin driver mode has been set in all the ways (pullup, pull down, resistive, strong etc.) with always the same result. I have the suspect of a macro error that I continue not to see. If someone has an idea welcome image

 

int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */


    for(;;)
    {
        STATUS_LED_1_Write(END_STOP_1_ReadDataReg());
        STATUS_LED_2_Write(END_STOP_2_ReadDataReg());
        CyDelay(500);
//        STATUS_LED_1_Write(0);
//        STATUS_LED_2_Write(1);
//        CyDelay(500);
//        STATUS_LED_1_Write(1);
//        STATUS_LED_2_Write(0);
//        CyDelay(500);
    }
}

 

For testing if the commented lines are uncommented LEDs blink correctly.

 

Thanks to all in advance for any suggestion.

Enrico

Attachments:
Prototype_NoPWM.cydsn.zip
  • Sign in to reply
  • Cancel

Top Replies

  • dougw
    dougw over 8 years ago +1 suggested
    I think ReadDataReg refers to the output status of the pin. If you use simply Read you should get the input status. STATUS_LED_1_Write(END_STOP_1_Read()); Doug
  • dougw
    dougw over 8 years ago in reply to balearicdynamics +1 verified
    Here is a setup screen from a door switch that works for me using the Read call: I did not need an external resistor. Doug
Parents
  • dougw
    0 dougw over 8 years ago

    I think ReadDataReg refers to the output status of the pin.

    If you use simply Read you should get the input status.

    STATUS_LED_1_Write(END_STOP_1_Read());

    Doug

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • balearicdynamics
    0 balearicdynamics over 8 years ago in reply to dougw

    Doug, this is the last test I have done. I hare used also the Read method only with always the same result. As a matter of fact, I don't exclude that it is my mistake somewhere in the circuit but there are some parts that I should be sure that are correct, to eliminate a too wide number of possibilities. So

     

    PIN_NAME_Read() will return an uint8, as far as I know, is correct?
    The connection fo the end-switch - it seems to me - does not need external resistors as are already managed by the PSoC, is correct?

     

     

    Then the pin driver mode, should be"high impedance digital" It is what I have read on the pin documentation on the PSoC bunch of pdf files but this was another aspect I was unsure, as well as the kind of connection. SHould be set a External terminal only or also HW connection ?

     

    In cases like this all things sounds certain becomes confused ... image

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • dougw
    0 dougw over 8 years ago in reply to balearicdynamics

    Here is a setup screen from a door switch that works for me using the Read call:

    image

    I did not need an external resistor.

    Doug

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • dougw
    0 dougw over 8 years ago in reply to balearicdynamics

    Here is a setup screen from a door switch that works for me using the Read call:

    image

    I did not need an external resistor.

    Doug

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • balearicdynamics
    0 balearicdynamics over 8 years ago in reply to dougw

    Thank you Doug! Tomorrow I will try the settings, but I am almost sure that should work also here.

     

    Enrico

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify 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