00001 /* analog.c --- 00002 * 00003 * Filename: analog.c 00004 * Description: 00005 * Author: Bryce Himebaugh 00006 * Maintainer: 00007 * Created: Mon Oct 16 11:02:32 2006 00008 * Version: 00009 * Last-Updated: 00010 * By: 00011 * Update #: 0 00012 * Keywords: 00013 * Compatibility: 00014 * 00015 */ 00016 00017 /* Commentary: 00018 * 00019 * 00020 * 00021 */ 00022 00023 /* Change log: 00024 * 00025 * 00026 */ 00027 00028 /* This program is free software; you can redistribute it and/or modify 00029 * it under the terms of the GNU General Public License as published by 00030 * the Free Software Foundation; either version 2, or (at your option) 00031 * any later version. 00032 * 00033 * This program is distributed in the hope that it will be useful, 00034 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00035 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00036 * GNU General Public License for more details. 00037 * 00038 * You should have received a copy of the GNU General Public License 00039 * along with this program; see the file COPYING. If not, write to the 00040 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00041 * Boston, MA 02111-1307, USA. 00042 */ 00043 00044 /* Code: */ 00045 00046 #include <msp430x16x.h> 00047 00048 void init_a2d(void) { 00049 // Setup the AD converter as follows: 00050 00051 // %% ADC12CTRL0 %% 00052 // Sample-and-Hold Time - 4uS (32 SMCLK) - with Rs=1k -> 1.88uS is required 00053 // 2.5V internal reference - 5V external signals are divided by 2 before the op-amp buffer 00054 // MSC bit tells convert to immediately convert next channel after started by SHI 00055 // 00056 ADC12CTL0 = SHT11+SHT10+SHT01+SHT00+MSC+REF2_5V+REFON+ADC12ON; 00057 ADC12CTL1 = SHP+ADC12DIV2+ADC12DIV1+ADC12DIV0+ADC12SSEL1+ADC12SSEL0+CONSEQ1+CONSEQ0; 00058 ADC12MCTL0 = 0x10; // AD0 00059 ADC12MCTL1 = 0x11; // AD1 00060 ADC12MCTL2 = 0x12; // AD2 00061 ADC12MCTL3 = 0x13; // AD3 00062 ADC12MCTL4 = 0x14; // AD4 00063 ADC12MCTL5 = 0x95; // AD5 (End of Sample Sequence) 00064 } 00065 00066 void init_dac(void) { 00067 DAC12_0CTL = DAC12LSEL_0 + DAC12IR + DAC12AMP_7 + DAC12ENC; 00068 DAC12_1CTL = DAC12LSEL_0 + DAC12IR + DAC12AMP_7 + DAC12ENC; 00069 } 00070 00071 /* analog.c ends here */
1.3.9.1