You can do this several ways.
1) Place a counter on schematic, say fixed 16 bit, and clock source and an ISR symbol to generate
Config counter as 1800 period, 60 secs x 30 minutes, interrupt on Tc. Place clock, sournce ILO (1 Khz),
and set its freq to 1 Hz. Note ILO has to be trimmed otherwise accuracy marginal. Or use buss clock,
its accuracy is +/- 5% (depends on what freq you clock with). ILO trimmed is - 50%, + 100%, or use 32
Khz xtal. Then in ISR flip pin that is driving LED.
2) Use RTC and set an alarm for every 30 minutes.
I want to set the time exchanging, Can I use this in RTC? I will set time with the button maybe 5 minute,then countdown 5 minutes led on. So, can i set the time with the button?How do you need to write a program for it? Thanks for answers
Design01.Bundle013.zip 1.4 MB
Answer is yes, you can change time with a button(s). Usually a button for
up, one for down, another for menu select.
1) Buttons would have to be debounced, generally in firmware by polling the
port with the pins in a for() or while() loop.
2) You debounce a button by detecting first closure, then timing out a period, on the order of
100 mS, and checking to see its still closed. If it is and doneflag == 0 then you do the function
assigned to that pin/button and set doneflag==1. Keep in mind you also have to debounce the
button open, and when it is open reset doneflag==0. The 100 mS can be done with a timer or
counter, and an ISR to inc a variable every 100 mS. 100 mS is switch dependent, but should
be OK for most switches.
Some debouce info that may be of help.
Debounce1.zip 3.9 MB
you can also use the debounce component from creator as well. It's all up to you. For simple test of idea, the hardware component would be quicker.
I examined documents. I'm trying to do something. if there's an example Can you send me?
Are you looking for a already finished solution to your problem?
Try to play around with the components. Look at the example projects available with the kits. Use a debouncer component to just drive a LED. Use the timer component to drive a LED (let it just blink). Then combine the two. It is not that complicated :)
If you have a question regarding a specific problem, don't hesitate to ask here (but open a new thread for new questions, please).
First, you could update Creator to the latest version, I was asked to update some components (but this should not be the source of your problems).
Second, since your button is connected to ground, you might want to use 'neg' output of the debouncer to detect button presses instead of using the NOT gate inbetween.
But most important, remove the first for-loop from your code - I think it gets stuck there instead of going to the second one containing your real code...
The main loop looks OK at a first glance, but you never update the 'temp1' variable. But you should not write an integer starting at column 14 - it might overflow (when it has more than 2 digits).
I saw that the LED pin you draw in the schematic is assigned to P6, but in the 'test' ISR you change P6. You should store the current state of the LED in a variable (e.g. a boolean) which gets toggled every ISR call and determines the output state. This is safer than directly reading the pin (e.g. you write a 1 to the pin, it starts to rise to 1, in the next ISR call you read the pin but get a 0 since it has not risen enough...)
No small number of training videos here -
www.cypress.com/ Take PSOC 3 and 5 101 thru 104.
Almost all components, when placed on a schematic, if you right click
them, have a menu selection "find example project" than you can add
to the design you are working on, or open in a new design window to
You are corerct to use the inverter, per AN60024 -
I would recommend setting clk to debouncer as 10 Hz, ie wait 100 mS
for all sw bounce to expire.
Add this to start of main() -
/* Enable global interrupts */
But this one-irq-too-much problem only happens if interrupts are already enabled when starting the debouncer component.
The reason I suggested to remove the inverter is that, right now, it iss a double negation. First the active-low button signal is converted to an active-high signal, and then the ISR is set to react on a rising flank - whereas in reality a falling flank is meant (to detect the button press). In my experience this always has great potential to confuse people...
If the button has a pull up resistor and connect to ground when press.
I will use the input directly to the debouncer, and only generate pulse on negative edge.
That means a (high) pulse will generate every time the button is pressed(connected to ground).