Texas Instruments MSC1210 User Manual

Page 159

Advertising
background image

Syncronizing Multiple MSC1210 Devices

12-23

Analog-to-Digital Converter

#include <REG1210.H>

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#define LSB 298.0232e−9 /* LSB=5.0/2^24 */

extern void autobaud(void);

extern long bipolar(void);

void main(void)

{

float volts, temp, resistance, ratio, lr, ave;

int i, k, decimation = 1728, samples;

autobaud();

printf(”MSC1210 Sync Example \n”);

//Timer Setup

USEC = 10;

// 11MHz Clock

ACLK = 9;

// ACLK = 11,0592,000/10 = 1,105,920 Hz

// modclock = 1,105,920/64 = 17,280 Hz

// Setup ADC

PDCON &= 0x0f7;

// turn on adc

ADMUX = 0x01; // Select AIN0/AIN1

ADCON0 = 0x30;

// Vref On, Vref Hi, Buff off, BOD off, PGA=1

ADCON2 = decimation & 0xFF; // LSB of decimation

ADCON3 =(decimation>>8) & 0x07; // MSB of decimation

ADCON1 = 0x01; // bipolar, auto, self calibration, offset, gain

while(sync == 0); // As long as sync is low, wait

// Now that sync is low, shut down ADC.

PDCON |= 0x08;

while(sync == 1); // As long as Sync is high, wait.

// When sync goes low, turn on ADC and continue

PDCON = ~0x08;

// At this point ADC is on and multiple MSC1210’s using the

// same Sync signal will be in syncronization.

} //main

Advertising