User`s guide

30
Appendix C – Useful registers
The contents of this chapter should be of little interest when using Simulink to generate the
code. Should one ever need to troubleshoot or decide to write segments of code by hand – the
registers shown below are of great interest. The reader should note that this chapter is not to
be considered a full reference guide – but merely a quick explanation of the F2812’s register
structure, a list of some of the most common ones and their functions.
The timer registers include the following: (same principle for timers 2-4)
Timer 1 Counter Register (T1CNT) Address 7401h
Timer 1 Compare Register (T1CMPR) Address 7402h
Timer 1 Period Register (T1PR) Address 7403h
Timer 1 Control Register (T1CON) Address 7404h
The first three are pretty straightforward – each containing a 16-bit value. T1CON on the
other hand, is well worth a closer look:
T1CON as seen in the Event Manager Reference Guide
Bit(s) Name Description
15:14 FREE, SOFT Emulation control bits
13 Reserved Reads return zero, writes have no effect.
1211 TMODE1TMODE0 Count mode selection
108 TPS2TPS0 Input clock prescaler
7 T2SWT1/T4SWT3
6 TENABLE Timer enable
54 TCLKS(1,0) Clock source
32 TCLD(1,0) Timer compare register reload condition
1 TECMPR Timer compare enable
0 SELT1PR, SELT3PR Period register select
A lot of options are available to the user by setting the correct flags, the register above for
example, offers the choice of external or internal clocks as well as setting the behaviour of the
internal clock. How to set flags was covered briefly in appendix A.