2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
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.
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.
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
18 * Revision : $Id: pwm_config.h,v 1.2.2.2 2007-05-12 16:42:38 zer0 Exp $
22 /* Droids-corp, Eirbot, Microb Technology 2005 - Zer0
25 /** \file pwm_config.h
26 \brief Module to operate all PWM outputs
36 /* Which PWM are enabled ? */
37 //#define PWM0_ENABLED
41 //#define PWM2_ENABLED
47 /** max value for PWM entry, default 12 bits > 4095 */
48 #define PWM_SIGNIFICANT_BITS 12
52 //#define TIMER0_MODE TIMER_8_MODE_PWM
53 //#define TIMER0_PRESCALE TIMER_8_PRESCALE_1
56 #define TIMER1_MODE TIMER_16_MODE_PWM_9
57 #define TIMER1_PRESCALE TIMER_16_PRESCALE_1
59 //#define TIMER2_MODE TIMER_8_MODE_PWM
60 //#define TIMER2_PRESCALE TIMER_8_PRESCALE_1
63 #define TIMER3_MODE TIMER_16_MODE_PWM_9
64 #define TIMER3_PRESCALE TIMER_16_PRESCALE_1
69 /** config for pwm and signs
71 The pwm mode is defined as follows :
72 you can add flags like the ones who follow :
74 PWM_NORMAL : normal pwm, just to put a value if nothing else is needed
75 PWM_REVERSE : invert pwm output, not sign
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%
83 the values of PWMxx_SIGN_PORT and PWMxx_SIGN_BIT are simply ignored if the PWM is not signed, but must be defined
86 if you need for example a PWM1A with special sign mode you configure like this :
88 #define PWM1A_MODE (PWM_SIGNED | PWM_SPECIAL_SIGN_MODE)
89 #define PWM1A_SIGN_PORT PORTB
90 #define PWM1A_SIGN_BIT 2
97 #define PWM1A_MODE (PWM_NORMAL)
98 #define PWM1A_SIGN_PORT PORTB // ignored
99 #define PWM1A_SIGN_BIT 2 // ignored
101 #define PWM1B_MODE (PWM_NORMAL)
102 #define PWM1B_SIGN_PORT PORTB // ignored
103 #define PWM1B_SIGN_BIT 2 // ignored
105 #define PWM1C_MODE (PWM_NORMAL)
106 #define PWM1C_SIGN_PORT PORTB // ignored
107 #define PWM1C_SIGN_BIT 2 // ignored
109 #define PWM3A_MODE (PWM_NORMAL)
110 #define PWM3A_SIGN_PORT PORTB // ignored
111 #define PWM3A_SIGN_BIT 2 // ignored
113 #define PWM3B_MODE (PWM_NORMAL)
114 #define PWM3B_SIGN_PORT PORTB // ignored
115 #define PWM3B_SIGN_BIT 2 // ignored
117 #define PWM3C_MODE (PWM_NORMAL)
118 #define PWM3C_SIGN_PORT PORTB // ignored
119 #define PWM3C_SIGN_BIT 2 // ignored
126 this makes the PWMs synchronized.
127 just activate the timers you want to synchronize
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.
134 side effect : on some controllers prescalers are shared, so unwanted prescalers can be reset.
136 This feature is not 100% shure for the moment, but has been tested on M32 and M128
139 //#define TIMER0_SYNCH
141 //#define TIMER2_SYNCH