Button press to enable power supply to PSoC4 and turn on LED at the same time

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

cross mob
Anonymous
Not applicable

Hello,

I have an input pin connected to a switch. Pressing the switch enables power to the PSoC4 chip (i.e. PSoC goes through complete bootloading process and then executes the main()).

The processor is initially cut off from the power source. Pressing the button generates a rising edge which turns the processor ON, however this rising edge of the button is also being used to turn an LED ON. Since the processor is booting, this rising edge does not generate interrupt and the LED is not turned ON. This is understandable because at that very instance, the processor isn't powered. So to turn the LED ON with the same pulse, I'm using the falling edge to generate an interrupt which turns the LED ON. However, I am wondering if there is any way to capture the same rising edge, i.e. if I can add some component in my top design to delay the pulse or repeat it.

Currently, I turn the LED ON on rising edge of button press, but just for this "special case" I am using the falling edge.

I would greatly appreciate for any ideas.

Thanks,

0 Likes
1 Solution
Anonymous
Not applicable

If your project has reached main(), then power has been activated, and if power has been activated, then there must have been a button push to trigger the power activation. Can't you just use the initialization in main() before running the application's while/for loop to turn the LED on?

Unless there is another case where you will reinitialize the project with, say, a CySysSoftwareReset(), then it should be simple to do.

As @user_1377889 mentioned, you can also set the default mode of the LED to be high and it will be set when leaving the bootup sequence.

You could also read the reset reason at powerup to determine if the unit was reset or first time turning on, and change the LED based on that, but it is a little more tricky.

View solution in original post

0 Likes
6 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

There are two points during the boot process where you have control over a pin:

1st When the defined pin properties are written and the pin comes out of High-Z state a LED can be lit.

2nd When main() starts execution you can read the button state and turn on the LED.

Bob

0 Likes
Anonymous
Not applicable

Hey Bob, thank you for the response.

Control over the pin when it comes out of high Z, by that do you mean having a direct connection between the pin and the LED? To read the pin from main() is a bit tricky because, I checked that the bootloader currently takes 700msec to complete and by the time it enters main(), the button press pulse is already over (considering typical button press of 200 - 300 msec).

Is it normal for the bootloader to take that long in PSoC4? Is there any way I can shorten that?

Thanks,

0 Likes

Control over the pin when it comes out of high Z, by that do you mean having a direct connection between the pin and the LED

Yes, the LED must be connected to any output pin. You may set the initial state in the configurator. This will be applied when the pin comes out of Hi-Z.

Bob

0 Likes
Anonymous
Not applicable

If your project has reached main(), then power has been activated, and if power has been activated, then there must have been a button push to trigger the power activation. Can't you just use the initialization in main() before running the application's while/for loop to turn the LED on?

Unless there is another case where you will reinitialize the project with, say, a CySysSoftwareReset(), then it should be simple to do.

As @user_1377889 mentioned, you can also set the default mode of the LED to be high and it will be set when leaving the bootup sequence.

You could also read the reset reason at powerup to determine if the unit was reset or first time turning on, and change the LED based on that, but it is a little more tricky.

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

From the description it is not clear how a momentary button switch turns on power to PSoC. Is there any other external latching circuit like relay, etc.?

Alternative way would be to power PSoC permanently, while putting it in deep sleep, and having it to wake up on the button press. This way PSoC can live on a battery for months.

/odissey1

0 Likes
Anonymous
Not applicable

Hi Odissey, thank you for your response.

Yes, the button press does enable power to the PSoC via external latching circuit. Once powered the PSoC does go into deepsleep when not in use and I use the global interrupt to wake up (and turn the LED ON), which works fine.

I'm facing this issue only when the system is booting for the first time.

0 Likes