August 17, 2011 Document No. 001-15340 Rev. *A
AN6073
11
Building a 1-ms Timer using Resources
on the CY7C64215
One common method is using an 8-bit PWM user module
and tweaking it to provide 1-ms interrupts. When there is a
constraint on resources, the user can configure the VC3
clock or the SOF interrupt sources to get 1-ms timer inter-
rupts. The three methods are explained below.
A. Configuring the 8-bit PWM in enCoRe III to behave as a 1-
ms interrupt timer.
The enCoRe III does not have a predefined 1-ms timer. How-
ever, one can be built from the 8-bit PWM user module avail-
able in enCoRe III. The steps for achieving this are given
below. A PSoC project that shows the basic configuration of
an 8-bit PWM as a 1-ms timer is attached with this project.
Note This project example was created solely for the purpose
of showing this conversion. The clock divider values may
change in your actual project and these should be accounted
for.
1. Start a PSoC Designer project with enCoRe III using ‘C’
for development.
2. Select the PWM user module and place it. (Select from
Device Editor - User Module Selection view and right click
in the Interconnect view to place it.)
3. In the Global Resources setting, choose VC1 = 16 and
VC2 = 6
4. In the User Module parameters section choose the
following:
– Clock = VC2 (This basically gives a clock of
24 MHz/96)
– Enable = high (to enable continuous count)
– Compare out = None
– Terminal Count = Row0 Output0 (To route the terminal
count signal to Port 0.0)
– Period = 255
– Interrupt type: Terminal Count (Terminal count hap-
pens every 256 periods of 24 MHz/96 clock =
1.024 ms)
– ClockSync: Sync to SysClk
– Invert Enable: Normal.
5. In the layout area, select Row0Output0 to
GlobalOutEven0.
6. In the Interconnect section select P0.0 to
GlobalOutEven0.
7. We are not concerned about Pulse Width and Compare
type since we are only looking to get 1-ms interrupt in this
example.
8. Hit the generate application button and go to the Applica-
tion Editor view.
9. In the main file, do the following:
– Enable Global interrupts
– Enable PWM interrupt
–Start PWM
10. In the PWM Interrupt ISR, custom code for 1-ms timer
interrupt can be included.
B. Configuring the VC3 clock divider to behave as a 1-ms
interrupt timer.
The VC3 clock can be used for 1-ms interrupt when there are
resource (digital blocks) constraints. Choosing the VC3 as
the 1-ms timer also gives greater flexibility to the system
clocks.
1. Select the appropriate VC3 clock source.
2. Choose a clock divider such that the output of VC3 gives
a 1-ms clock.
3. The interrupt is generated for every number of input clock
cycles = VC3 divider value+1
So if VC3 is sourced with a 1 KHz source and we choose the
divider value to be ‘0’, then interrupt occurs every cycle
(divider value+1 = 1) of the source i.e., every millisecond.
C. Using the USB SOF interrupt to behave as a 1-ms inter-
rupt timer.
The USB SOF interrupt occurs every 1 ms. Thus, the USB
SOF ISR can contain 1-ms ISR code. The USB SOF interrupt
only happens when there is USB traffic and may not be suit-
able in certain situations.
Summary
The CY7C64215 is functionally similar to the CY7C64x13
with integrated functionalities and configurable blocks. It has
a GUI based tool—PSoC Designer—that makes develop-
ment easy. This application note, with the PSoC TRM and the
enCoRe III data sheet will simplify the task of migrating
designs from CY7C64x13 to CY7C64215.
Komentáře k této Příručce