16.3.11 Cascading Pulse Counters
When two or more Pulse Counters are available, it is possible to cascade them. For example two 16-bit Pulse Counters can be casca-
ded to form a 32-bit pulse counter. This can be done with the help of the CNT UF/OF PRS and CNT DIR PRS ouputs. The figure
16.14 PCNT Cascading to two 16-bit PCNT to form a 32-bit PCNT on page 460
illustrates this structure.
PCNT0(LSB)
[15:0
OVSSINGLE MODE /
EXTCLKSINGLE MODE /
EXTCLKQUAD MODE /
OVSQUAD1X /
OVSQUAD2X /
OVSQUAD4X
PCNT1(MSB)
[31:16]
EXTCLK SINLGE MODE
PRS
Combinational
Matrix
prs_ufof
prs_dir
PRS
enable
and
input
select
PCNT Core
S0IN
S1IN
PRS CHANNELS
Figure 16.14. PCNT Cascading to two 16-bit PCNT to form a 32-bit PCNT
For cascading of Pulse Counters to work, the PCNT1 according to the figure
Figure 16.14 PCNT Cascading to two 16-bit PCNT to form
should be programmed in EXTCLKSINGLE mode and its S0IN and S1IN inputs should be configured to
prs_ufof and prs_dir of PCNT0 respectively. In addition to this, a strict programming sequence needs to be followed to ensure both
PCNTs are in sync with each other.
• Configure PCNT0 registers. eg. PCNT0_INPUT,PCNT0_CTRL,PCNT0_OVSCFG etc.
• Wait for PCNT0_SYCNBUSY to be cleared to ensure the registers are synchronized to the asynchronous clock domain.
• Hold PCNT0 in sw reset by setting PCNT0_CTRL_RSTEN.
• Configure PCNT1_CTRL to EXTCLKSINLE mode with S1CDIR and CNTDIR bit set. Configure INPUT to accept "prs_ufof" and
"prs_dir" of PCNT0 on S0IN and S1IN respectively.
• Wait for PCNTn_SYCNBUSY to be cleared to ensure the registers are synchronized to the asynchronous clock domain. Use three
PRS_SWPULSE on the S0IN prs channel to ensure this synchronization.
• Hold PCNT1 in sw reset by setting PCNT1_CTRL_RSTEN.
• Clear PCNT1_CTRL_RSTEN and synchronize it by asserting two PRS_SWPULSE on the S0IN input.
• Finally clear PCNT0_CTRL_RSTEN and start counting.
Note:
When RSTEN in PCNTn_CTRL is set, the TOP value in the Pulse Counter gets cleared. Therefore, in order to update the TOP value
while RSTEN is set, assert TOPBHFEN bit in PCNTn_CTRL. This will update the TOP value with the TOPB value even without having
to synchronize the TOPB value. This only works if TOPBHFEN and TOPB are configured while RSTEN in PCNTn_CTRL is set.
Reference Manual
PCNT - Pulse Counter
silabs.com
| Building a more connected world.
Rev. 1.1 | 460