HomeTOOLSEXAMPLESEXPLORE EMBEDDEDE CSERVICESECU SAMPLESRegistration
Embedded C programming Tutorial , Keil C ide , microsoftware.gr
Keil CRC and CAN BUS codes.
1. Shift led left
2.It's time for DAVE! <7/6/13>
3.Capture/Compare unit 6
4.ASC0-GPT1-MACROS
5.ASC0-FIFO-PEC
6.Analog converter
7.Memory manipulation routines
8. Recursion
9.Understanding interrupt priorities using CAPCOM2 module
10. POINTERS TO FUNCTION <4/7/13>,<4/28/13>
11.Memory models, memory types
12. The heap , part 1
13. The heap , part 2
14. The heap , part 3
15. Structure example
16. Nested structures, Array of structures.
17. Passing array of structures to function using pointers.<1/5/13>
18. Self Referential Structures
19. BITFIELDS
20. Linked list example
21. Circular linked list
22. Union example
23. Enumeration example
24. Watchdog timer example
25. Void pointer example <7/4/13>
26. The sieve of Eratosthenes
27. The stack
28. Union and bitfields as flags example. <6/23/13>
29. Look up table example. <8/11/13>
30. Seven segment display multiplexing -four digits with dot- example
31. LCD character display example - JHD162A
32. Hash table introduction example <8/27/14>
33. Array of Linked Lists example
34. Array of Linked lists-more functions included.
35. Hash table construction,searching and printing.
36. Fininte state machines- a first approach.
37. Finite state machines- two events example.
38. SPI port and an AT25128 serial eeprom hardware.
39. CRC CHECK
40. Definite Integral Calculator for Scientists, Engineers...
41 .Hamming distance of a CRC polynomial
42. Linux play starting.
43. Galois GF(2^4) Finite Field
44. Construct your own time triggered real time operating system.
45. CANBUS C CODE EXAMPLE.
3.Capture/Compare unit 6
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!

 




 

Home|TOOLS|EXAMPLES|EXPLORE EMBEDDEDE C|SERVICES|ECU SAMPLES|Registration