Digital Input pin state not updating

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaHu_285096
Level 5
Level 5
10 likes received 250 replies posted 100 replies posted

I have an issue that has never appeared before. I am running PSOC creator 4.2 and Device is 5LP.

I have a switch to ground on pin 12.7

In the main loop the code reads the switch and stores into volatile uint8 "myID".

ie: myID = SW1_Read();

If I run with debugger the value changes between 0 and 1 shenw I change switch position.

When I program the code into the target, it reads the correct value on start but if I change the switch while it is running it does not update to new value.

0 Likes
1 Solution

I constructed a new board with only the PSU, micro and Hex switch and it works fine after programming and removal and reapplying power.

The original boards were potted with silicon compound, I suspect the compound has leached up into the switches and and pushed the contacts apart.

View solution in original post

0 Likes
7 Replies
NoriTan
Employee
Employee
25 sign-ins 5 questions asked 10 sign-ins

Please confirm if your target has an pull-up resistor at the pin 12.7 or the pin component is configured as "Resistive pull up"  drive mode.

GS004302.png

Regards,

Noriaki

0 Likes

Yes, I have pull up resistor enabled on input and initial state = "1"

It works perfect when running on debugger but when I program the part it does not.

I have never had this issue with reading IO pins to date.

The micro restarts ok. I can get it to flash some leds on boot to make sure it is running. But does not read correct state of input pin.

0 Likes

Please add some delay prior to get the MyID like

CyDelay(1000);

myID = SW1_Read();

This solution is effective if the settling time of the input port is too long

Regards,

Noriaki

0 Likes

I cannot put a long delay before read because another device polls this one on power up (around 200ms after power up). It works on all previous versions of the project ok.

0 Likes

I constructed a new board with only the PSU, micro and Hex switch and it works fine after programming and removal and reapplying power.

The original boards were potted with silicon compound, I suspect the compound has leached up into the switches and and pushed the contacts apart.

0 Likes

DaHu,

Try another pin for testing purpose. It may happen that pin is blown already if it accidentally was set to "strong drive" or "open drain drive high" mode.

/odissey1

0 Likes

The problem seems to occur after power up of hardware.

If the hardware is already powered and I re-program it, the input works ok.

If I switch power off and back on and then program the hardware, it does NOT work. The switch gets read on power up and sets ID but I cannot change the ID by changing switch position.

If I run in debug mode then I can change channel ok, system reads switch fine.

This occurs even if I add 1000 ms delay before switch read.

0 Likes