180 likes | 664 Views
Programmable Counter Array PCA. Programmable Counter Array: PCA0. Clock sources: SYSCLK Internal oscillator: SYSCLK: F PCA = 2MHz SYSCLK/4 : F PCA = 500 KHz SYSCLK/12 : F PCA = 167 KHz SYSCLK External oscillator: SYSCLK : F PCA = 22.1184 MHz SYSCLK/4 : F PCA = 5.5296 MHz
E N D
Programmable Counter Array PCA EE/CS-352: Embedded Microcontrollers Systems
Programmable Counter Array: PCA0 • Clock sources: • SYSCLK Internal oscillator: • SYSCLK: FPCA= 2MHz • SYSCLK/4 : FPCA = 500 KHz • SYSCLK/12 : FPCA = 167 KHz • SYSCLK External oscillator: • SYSCLK : FPCA = 22.1184 MHz • SYSCLK/4 : FPCA = 5.5296 MHz • SYSCLK/12 : FPCA = 1.8432 MHz • Timer 0 Overflow: • Slowest: internal oscillator/12 * FFFF : FPCA = 2.55 Hz • Custom: ECI (External Clock Interface) • max FPCA rate is SYSCLK/4. Fastest Slowest EE/CS-352: Embedded Microcontrollers Systems
PCA0MD: PCA0 Mode Register PCA0 Counter/Timer Idle Control. Specifies PCA0 behavior when CPU is in Idle Mode PCA Counter/Timer Overflow Interrupt Enable EE/CS-352: Embedded Microcontrollers Systems
PCA Control Register: PCA0CN Compare/Capture Flags PCA Counter/Timer Overflow Flag Counter/Timer Run Control (enable) CF and CCFn can both be enabled to cause interrupt. Only one PCA interrupt vector, so if both are enabled, software must check to see which caused interrupt EE/CS-352: Embedded Microcontrollers Systems
PCA0CPMn Registers Capture Mode EE/CS-352: Embedded Microcontrollers Systems EE/CS-352: Embedded Microcontrollers Systems
PCA – Capture Mode Checks for transition on a CEXn input, and when found, loads value of PCA counter/timer in the capture register: PCA0CP EE/CS-352: Embedded Microcontrollers Systems
PCA – Capture Mode Example: configured for rising edges – frequency measurement: CCFn flag goes high (interrupt if enabled) PCA0 counter value is “captured” in PCA0CP register. Store value. • CCFn flag goes high (interrupt if enabled) • PCA0 counter value is “captured” in PCA0CP register. • Store value. • Subtract this value from the previous value to calculate period. • Frequency is 1/T EE/CS-352: Embedded Microcontrollers Systems
PCA0CPMn Registers Frequency Output Mode EE/CS-352: Embedded Microcontrollers Systems
Frequency Output Mode • Produces a programmable-frequency square wave on the module’s associated CEXn pin. • The capture/compare module high byte holds the number of PCA clocks to count before the output is toggled. Examples: FCEXn = 10 KHz For FPCA = 22.1184 MHz PCA0CPHn = 1106 = 451h For FPCA = 2 MHz PCA0CPHn = 100 = 64h does not fit! Must select clock source appropriate for frequency EE/CS-352: Embedded Microcontrollers Systems
Make some waves! Frequency Output Generation EE/CS-352: Embedded Microcontrollers Systems