Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
Michael_K
Level 3
Level 3
25 replies posted 10 likes given 50 sign-ins

Hello everyone,

I have the following problem: My colleague has built a small box with 3 switches for demo purposes. An off and on switch and two switches that trigger an interrupt. This works, but the problem is that sometimes interrupts are triggered by some kind of disturbance impulses.

In order to avoid an accidental activation, I simply wanted to build in a counter that, for example, only runs the demoprogram when pressed for 500ms.

I had something like that for another project:

Michael_K_0-1684234587998.png

Pin9 was connected to a switch and defined as input and  drive as resistive pull up. I then built up these blocks and was able to define a threshold with the timer counter, from when it accepts the keystroke as a press. This works fine.

This was for the PSoC 4200D , now I have an PSoC 4100S. (CY8C4126AXI-S433)

Okay, the PSoC 4100S doesn't have a debouncer, but it doesn't matter for now. I want to measure the duration of the pressed switch. But when I want to select the drive mode resistive pull down, I get the following error message:

Invalid Parameter:
Error 1: Pin 0: Use of drive modes which are not High Impedance with a hardware-routed input requires a port adapter, but the selected device does not have one.

Michael_K_0-1684246031616.png

When I change the drive mode to high impedance digital, I don't measure anything and the ISR won't occur.

Michael_K_1-1684246276707.png

If I use the pin without HW connection, then it also works as a pull down pin and I can trigger ISR with it, but I don't know how I can realise it with the longer button presses if I can't use the HW connection.

I used the document to see if I had missed anything somewhere:

https://www.infineon.com/dgdl/Infineon-AN86439_PSoC_4_Using_GPIO_Pins-ApplicationNotes-v12_00-EN.PDF...

 

Best Regards

Michael 

 

 

 

 

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

I suspect that your PCB has been designed for HiZ  pin configuration, with additional series resistor on each Pin (see Figure below).  Can you obtain the PCB schematic (only the portion relevant to the buttons)?

Attached is updated project. Here the inputs are configured for HiZ, with button pressed event corresponding to pulling the input to Vdd (+5V).  

The project is untested (I don't have P4100S board to test it). 

ButtonSw_P4100_HiZ_A.png 

View solution in original post

13 Replies
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

The issue you facing is that P4100 has limited configurability of the Pins, compared to P4200. It can't be configured both for hardware connection and Resistive Pull Up. However, it seems possible to configure it for Resistive Pull Up without connection to hardware. In this case the only choice left is to poll Pin state.

For simple button debouncing there is an existing component ButtonSw32:

ButtonSw32: button switch debouncer component 

 

I slightly updated it to run on PSoC4100S, however, I don't have PSoC4100S to test it. Provided below is a (untested) demo project using ButtonSw32 component to debounce 3 buttons. The ButtonSw32 component is included into the project. Please read the component datasheet  and AppNote for details.

Component uses Vertical Stack Counters algorithm to check the state of the input Pins on clock interrupt. If 4 consecutive readings of the pin state are the same, the state is accepted. Therefore, the debouncing time equals four WDT0 periods. As shown, the debouncing time equals 100msec.

Project archive is attached. It was last compiled using Creator v4.4.

 

 

Figure 1. Project schematic. The user-provided interrupt WdtIsr driven by the WDT0 timer polls the state of the pins at approx. 40 Hz rate. ButtonSw_P4100_WDT_A.png

 

Figure 2. The WDT0 Timer configuration. The Timer is configured as 'Periodic Timer' with divider 1000, providing approx. 40Hz polling period. The debouncing time equals 4 periods.

ButtonSw_P4100_WDT_Clocks.png

 
 
 

 

RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Can you use an external pull-down resistor? There is a limitation when connecting a pin to a TCPWM. The inputs have to use high impedance drive mode. 

0 Likes
lock attach
Attachments are accessible only for community members.
Michael_K
Level 3
Level 3
25 replies posted 10 likes given 50 sign-ins

Thanks for your replys. Here an update

@odissey1 : I tried your project and adapted it to a push switch and the other free GPIO I connected to an LED, as the other pins are already occupied.
The LED did not change its status. When I debugged the program, the if statement did not recognise that the switch had been pressed.

Maybe I will poll the pin state in the main loop, if I don't find a more elegant way.

@RodolfoGL In the box there are already pull-down-resistors. Both buttons are wired as shown in the picture, but for the PSoC 4100. In the high impedance drive mode, the ISR won't recognise. But if I do the same circuit with the 042 Pioneer Kit, then it recognises an interrupt, but counts only 0 on the timer counter. I have upload both projects. 

Michael_K_0-1684320294588.png

 

Best Regards

Michael 

 

0 Likes

As a debugging steps I would suggest:

1. Check that the WDT0 Timer operates properly. Add some LED Pin toggle in the interrupt routine to make sure it is firing at 25ms intervals. Like: Pin_X_Write(~Pin_X_Read()); 

2. Note that component automatically configures the button pins as Resistive Pull Up. Check with a scope or a multimeter that they are at +5V. The component responds on Pin being shorted to the ground on the Button  press  event (it seems that you are using Buttons pulling up to +5V instead).

3. Configure a project for a single Button to check if there any Pin assignment issues.

4. In the demo the LED Pins are configured to pull down to turn LEDs on. Do you have an opposite polarity? 

 

P.S. The project provided was last compiled using Creator v.4.4. It will not run on Creator v4.0 or earlier versions. I am not sure how you managed to test it using old version of the Creator IDE. I can compile the project using Creator 4.0 if this helps  

0 Likes

I see you are using an old version of PSoC Creator (or at least some old components).

Please download PSoC Creator 4.4 and PDL 3.1.

Update all the components to the latest version. Tools > Find New Components and Project > Update Components.

About the logic in the Timer component, I would leverage the count input setup on LEVEL to count and only use the reload on rising edge. No need to use the start/stop/capture input signals. 

0 Likes
Michael_K
Level 3
Level 3
25 replies posted 10 likes given 50 sign-ins

@odissey1 Here is already an error, the WDT0 timer does not toggle the LED in 25ms intervals, but is 1.3 seconds on and 1.3 seconds off.

Michael_K_0-1684508282739.png

 

I will ask my colleague again exactly how he wired the switches, because I can't reach it.

I use PSoC Creator 4.4. and I have update the components.

 

@RodolfoGL I will try the on LEVEL to count on Monday. I will not make it today.

 

Thanks for your replys and I will keep your up to date 🙂

Michael

0 Likes
lock attach
Attachments are accessible only for community members.

It seems that the WDT timer configuration is different from the P4200 from which the code was originally borrowed. To make things simpler, I drafted a new project, which doesn't use the WDT timer. Instead it utilizes a standard TCPWM block to trigger the interrupt. Project is attached.

ButtonSw_P4100_basic_A.png  

0 Likes
Michael_K
Level 3
Level 3
25 replies posted 10 likes given 50 sign-ins

Hello everyone,

@odissey1 I tried your new project. The timer is called every 25ms, which is fine. It worked for the first time when I changed the resistor value from 10k to 330Ohm, or omitted the resistor completely and connected the GPIO directly to ground via the switch, as in the image.

Michael_K_0-1685091783345.png

The problem now is that the box with the two switches with 10k resistors act as a pulldown and the switch is connected to Vdd. 

@RodolfoGL Even though I changed the count input setup on LEVEL to count and only use the reload on rising edge, it does not work with the high impedance input. Nothing is counted in the ReadCapture().

 

Regards

Michael

0 Likes
lock attach
Attachments are accessible only for community members.

In the original project, the input Pins were configured for Resistive Pull Up mode. Therefore all they need is a button with direct connection to the GND (no external resistors required). 

Here, I modified the underlying component (ButtonSw32) to respond to the Button shorting to +Vdd. In this case, the Pins are configured for Resistive Pull Down. The Pin internal resistor is about 5-7k, so no external resistor is required. However, if you already have 10k resistor to the GND, it is Ok to leave it in place.

Project is attached.

ButtonSw_P4100_PullUp_A.png 

Michael_K
Level 3
Level 3
25 replies posted 10 likes given 50 sign-ins

Hello

@odissey1 : I don't know what I'm doing wrong, but it doesn't work either 🤔. I measure a HIGH level with the oscilloscope, but the state of the LED does not change.

Michael_K_0-1685525675171.png

Best Regards

Michael

0 Likes

The project was tested using PSoC5LP  (I have no P4100S board) and worked fine. Can you please check that the interrupt is fired at 40Hz, and that the input/output pins are assigned correctly and that the input goes to +5V on button press event? Try to remove 10k resistor (theoretically, it should make no difference, but who knows?). Is there by any chance input resistors in series or capacitors in place? Do you have a custom PCB or a prototyping board?

0 Likes
Michael_K
Level 3
Level 3
25 replies posted 10 likes given 50 sign-ins

Hello,

@odissey1 Without the 10k pulldown resistor it works. It is a self-made board, but not made by me, but by my colleague.  

 

Best Regards

Michael 

0 Likes
lock attach
Attachments are accessible only for community members.

I suspect that your PCB has been designed for HiZ  pin configuration, with additional series resistor on each Pin (see Figure below).  Can you obtain the PCB schematic (only the portion relevant to the buttons)?

Attached is updated project. Here the inputs are configured for HiZ, with button pressed event corresponding to pulling the input to Vdd (+5V).  

The project is untested (I don't have P4100S board to test it). 

ButtonSw_P4100_HiZ_A.png