Egg Timer Tutorial
Egg Timer Tutorial
I. Introduction
This tutorial introduces PSoC Creator design and consists of:
1. Creating a system comprising PWM, clock, Interrupt (interrupt service routine interface), digital
output port and LCD display.
2. Output pins assignment for PSoC 3 Dev. Kit CY8CKIT-030
3. Software - main.c
4. Programming the CY8CKIT-030
Design Example: An egg timer (a culinary term) is a device used for timing when T0 seconds has elapsed.
This tutorial demonstrates its use for blinking LED with a 1-s on/off period. The design uses PWM
terminal count interrupt to provide 200 ms interval interrupts. The interrupt service subroutine counts
the number of times interrupt happens and sets a time-expired flag when the count corresponds to 1 s.
II. Creating System
1. File -> New Project. Name the project egg_timer.
the system is built. On the top bar above the Workspace pace comprises buttons for build, compile,
program the device and debug.
3. The steps in this section build the system below. Open TopDesign.cysch in the Workspace.
3.5 PWM parameters: Double click on the component and set these parameters
Parameters:
Return Value:
Side Effects:
The main program (see void main() below) calls this function PWM_isr_SetVector(my_PWM_TC_isr;
which declares an address name my_PWM_TC_isr (PWM Terminal Count interrupt service routine) for
the isr code. The isr code begins with CY_ISR with the address.
Upon an interrupt from the PWM terminal count, if Time_Expired flag not set increment count. If count
reaches Max_Count set the flag and reset the count. LCD is used for debugging. Clear any pending on
PWM interrupt flag. Read status register of the PWM to clear the register. (From the PWM datasheet
The status register is a clear-on-read register so the interrupt source is held until the
PWM_ReadStatusRegister() function is called.)
4.3 void main()
4.3.1 Between global interrupt disable and enable, start and initialize all the peripherals. The address for
the interrupt service routine declared to be PWM_TC_isr. Disable the isr component initially.
4.3.2 Testing the Egg Timer by driving the digital output port (to be connected to an LED) high and low
with 1 sec period, that is, the isr sets the Time_Expired flag once count = Max_Count.
5. Open egg_time.cydwr. Edit the pins for my_LCD to P2[6:0] and Digital_Out_LED to P6[3]