This article explains capcom6 unit
It is important for a mocrocontroller to be able to measure time and to connect time with the capture of an event. Why?
When you want for example to measure the passed time when an event is appeared or to measure the time distance between two events.
How a microcontroller can measure time? Of course not using your hand-held clock!
It uses its time base made by timers inside the chip and counter registers that count and save timer 'tics'.
The total amount of counted pulses is the total time.
Such a module is the Capcom6 unit, capture/compare unit6.
Capture: Connects events with time.
Compare: compare event appearence time with a pre-determinded time value.
Here we will exam the compare mode. Capcom6 uses 2 timers as time bases. Timer12 and timer13. We will use timer12.
Capcom6 includes 3 independent chanels that they are all together connected to timer T12. But each chanel has its own compare register. Inside the compare register we can set our predeterminded number of pulses and when the counted pulses that come from T12 matches this number ,then the chanel will change its output state. It is obvious that the three chanels will change their output stages at different passed times, due to different pre-settings in their compare registers.
Now, timer T12 can count at two different modes:
1. Center-alligned mode. It counts up and down passing from zero counted number of pulses .
See figure. So we have two matcing points per period and per chanel.
2. Edge-alligned mode. We have only one match point per period and per chanel.see figure.
The output stage is the outputs of the three chanels of CAPCOM6 unit. These are the CC60, CC61, CC62. We use and the output pins of the 'shadow' registers of the three chanels , these are :cout60
,cout61, cout62. We use this pins in this articl to have the inverse logic state than cc60, cc61, cc62.
So the total used pins for the output stage of capcon6 are 6, 2 pins per chanel. see figure.
These pins are conected to the led of the development board at the parallel port P1L (it is used now by capcon6 !) as in the table:
/// -----------------------------------------------------------------------
/// Configuration of the used CCU6 Channel Port Pins:
/// -----------------------------------------------------------------------
/// - P1L.0 is used for CAPCOM6 output (CC60)
/// - P1L.2 is used for CAPCOM6 output (CC61)
/// - P1L.4 is used for CAPCOM6 output (CC62)
/// - P1L.1 is used for CAPCOM6 output (COUT60)
/// - P1L.3 is used for CAPCOM6 output (COUT61)
/// - P1L.5 is used for CAPCOM6 output (COUT62)
You can find it at the CCU6.C file of the DAVE project.
Of course we use DAVE to make the two projects, one project per each T12 counting mode.
capcom6 center-alligned mode take it.
capcom6 edge-alligned mode take it.
see the video
Open the projects by DAVE hiting on capcom6 module and observe the selections. Observe the different
preset match number of pulses per each of the three chanels.
Exercise: Using one of the three chanels of capcom6 unit you can make a pulse waveform having the duty cycle that you want. Duty cycle = On time divided by the period of the pulse. For example you can make duty cycles 80%, 50%, 20% etc. The only job that you have to do is to use the capcom6 center-alligned mode project and to load the compare register of the chanel with the right match counted number of pulses.
Help: Use DAVE and set your desired duty cycle under the 'control' window. Leave DAVE to do the rest of the job!
|