ini
[aversive.git] / modules / devices / brushless_motors / brushless_3phase_digital_hall_double / test / pwm_config.h
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: pwm_config.h,v 1.2.2.2 2007-05-12 16:42:39 zer0 Exp $
19  *
20  */
21
22 /* Droids-corp, Eirbot, Microb Technology 2005 - Zer0
23  * Config for PWM
24  */
25 /** \file pwm_config.h
26     \brief Module to operate all PWM outputs
27
28     \test not tested
29  
30 */
31
32
33 #ifndef _PWM_CONFIG_
34 #define _PWM_CONFIG_
35
36 /* Which PWM are enabled ? */
37 //#define PWM0_ENABLED
38 #define PWM1A_ENABLED
39 #define PWM1B_ENABLED
40 #define PWM1C_ENABLED
41 //#define PWM2_ENABLED
42 #define PWM3A_ENABLED
43 #define PWM3B_ENABLED
44 #define PWM3C_ENABLED
45
46
47 /** max value for PWM entry, default 12 bits > 4095 */
48 #define PWM_SIGNIFICANT_BITS 12
49
50 // timer configs
51
52 //#define TIMER0_MODE     TIMER_8_MODE_PWM
53 //#define TIMER0_PRESCALE TIMER_8_PRESCALE_1
54
55 // 31 kHz PWM
56 #define TIMER1_MODE     TIMER_16_MODE_PWM_9
57 #define TIMER1_PRESCALE TIMER_16_PRESCALE_1
58
59 //#define TIMER2_MODE     TIMER_8_MODE_PWM
60 //#define TIMER2_PRESCALE TIMER_8_PRESCALE_1
61
62 // 31 kHz PWM
63 #define TIMER3_MODE     TIMER_16_MODE_PWM_9
64 #define TIMER3_PRESCALE TIMER_16_PRESCALE_1
65
66
67
68
69 /** config for pwm and signs
70
71 The pwm mode is defined as follows :
72 you can add flags like the ones who follow : 
73
74 PWM_NORMAL            : normal pwm, just to put a value if nothing else is needed
75 PWM_REVERSE           : invert pwm output, not sign
76
77 PWM_SIGNED            : activate the sign output on a port (see config)
78 PWM_SIGN_INVERTED     : invert sign output
79 PWM_SPECIAL_SIGN_MODE : if defined, the pwm is always near 0 for low values, 
80                         else negative low values are near 100%
81
82
83 the values of PWMxx_SIGN_PORT and PWMxx_SIGN_BIT are simply ignored if the PWM is not signed, but must be defined
84
85
86 if you need for example a PWM1A with special sign mode you configure like this : 
87
88 #define PWM1A_MODE       (PWM_SIGNED | PWM_SPECIAL_SIGN_MODE)
89 #define PWM1A_SIGN_PORT  PORTB
90 #define PWM1A_SIGN_BIT   2
91
92 */
93
94
95
96 // PWM definitions
97 #define PWM1A_MODE       (PWM_NORMAL)
98 #define PWM1A_SIGN_PORT  PORTB // ignored
99 #define PWM1A_SIGN_BIT   2 // ignored
100
101 #define PWM1B_MODE       (PWM_NORMAL)
102 #define PWM1B_SIGN_PORT  PORTB // ignored
103 #define PWM1B_SIGN_BIT   2 // ignored
104
105 #define PWM1C_MODE       (PWM_NORMAL)
106 #define PWM1C_SIGN_PORT  PORTB // ignored
107 #define PWM1C_SIGN_BIT   2 // ignored
108
109 #define PWM3A_MODE       (PWM_NORMAL)
110 #define PWM3A_SIGN_PORT  PORTB // ignored
111 #define PWM3A_SIGN_BIT   2 // ignored
112
113 #define PWM3B_MODE       (PWM_NORMAL)
114 #define PWM3B_SIGN_PORT  PORTB // ignored
115 #define PWM3B_SIGN_BIT   2 // ignored
116
117 #define PWM3C_MODE       (PWM_NORMAL)
118 #define PWM3C_SIGN_PORT  PORTB // ignored
119 #define PWM3C_SIGN_BIT   2 // ignored
120
121
122
123 /** 
124 PWM synchronization.
125
126 this makes the PWMs synchronized.
127 just activate the timers you want to synchronize
128
129 to synch PWMs you need to enshure that the timers have same prescales. This is verified.
130 you need also to enshure that the PWM mode is the same, this is NOT verified !!
131 especially, for syncing 8 and 16 bit timers, the PWM mode should be 8 bit.
132
133
134 side effect : on some controllers prescalers are shared, so unwanted prescalers can be reset.
135
136 This feature is not 100% shure for the moment, but has been tested on M32 and M128
137 */
138
139 //#define TIMER0_SYNCH
140 #define TIMER1_SYNCH
141 //#define TIMER2_SYNCH
142 #define TIMER3_SYNCH
143
144
145
146 #endif
147