adc.h File Reference

AD Routines. More...

#include "TIMotorLIB.h"
#include "IQConstants.h"
#include "DataStorage.h"

Go to the source code of this file.

Data Structures

struct  ADConfiguration
 storing of AD configuration data More...

Defines

#define MAX_CH   16
#define ADCINA0   0
#define ADCINA1   1
#define ADCINA2   2
#define ADCINA3   3
#define ADCINA4   4
#define ADCINA5   5
#define ADCINA6   6
#define ADCINA7   7
#define ADCINB0   8
#define ADCINB1   9
#define ADCINB2   10
#define ADCINB3   11
#define ADCINB4   12
#define ADCINB5   13
#define ADCINB6   14
#define ADCINB7   15
#define CH0_RAW   ((AdcRegs.ADCRESULT0 & 0xFFF0) >> 4)
#define CH1_RAW   ((AdcRegs.ADCRESULT1 & 0xFFF0) >> 4)
#define CH2_RAW   ((AdcRegs.ADCRESULT2 & 0xFFF0) >> 4)
#define CH3_RAW   ((AdcRegs.ADCRESULT3 & 0xFFF0) >> 4)
#define CH4_RAW   ((AdcRegs.ADCRESULT4 & 0xFFF0) >> 4)
#define CH5_RAW   ((AdcRegs.ADCRESULT5 & 0xFFF0) >> 4)
#define CH6_RAW   ((AdcRegs.ADCRESULT6 & 0xFFF0) >> 4)
#define CH7_RAW   ((AdcRegs.ADCRESULT7 & 0xFFF0) >> 4)
#define CH8_RAW   ((AdcRegs.ADCRESULT8 & 0xFFF0) >> 4)
#define CH9_RAW   ((AdcRegs.ADCRESULT9 & 0xFFF0) >> 4)
#define CH10_RAW   ((AdcRegs.ADCRESULT10 & 0xFFF0) >> 4)
#define CH11_RAW   ((AdcRegs.ADCRESULT11 & 0xFFF0) >> 4)
#define CH12_RAW   ((AdcRegs.ADCRESULT12 & 0xFFF0) >> 4)
#define CH13_RAW   ((AdcRegs.ADCRESULT13 & 0xFFF0) >> 4)
#define CH14_RAW   ((AdcRegs.ADCRESULT14 & 0xFFF0) >> 4)
#define CH15_RAW   ((AdcRegs.ADCRESULT15 & 0xFFF0) >> 4)
#define CH0_RAW_MIRROW   (AdcMirror.ADCRESULT0)
#define CH1_RAW_MIRROW   (AdcMirror.ADCRESULT1)
#define CH2_RAW_MIRROW   (AdcMirror.ADCRESULT2)
#define CH3_RAW_MIRROW   (AdcMirror.ADCRESULT3)
#define CH4_RAW_MIRROW   (AdcMirror.ADCRESULT4)
#define CH5_RAW_MIRROW   (AdcMirror.ADCRESULT5)
#define CH6_RAW_MIRROW   (AdcMirror.ADCRESULT6)
#define CH7_RAW_MIRROW   (AdcMirror.ADCRESULT7)
#define CH8_RAW_MIRROW   (AdcMirror.ADCRESULT8)
#define CH9_RAW_MIRROW   (AdcMirror.ADCRESULT9)
#define CH10_RAW_MIRROW   (AdcMirror.ADCRESULT10)
#define CH11_RAW_MIRROW   (AdcMirror.ADCRESULT11)
#define CH12_RAW_MIRROW   (AdcMirror.ADCRESULT12)
#define CH13_RAW_MIRROW   (AdcMirror.ADCRESULT13)
#define CH14_RAW_MIRROW   (AdcMirror.ADCRESULT14)
#define CH15_RAW_MIRROW   (AdcMirror.ADCRESULT15)
#define BITS2VOLTS(bits)   ((bits >> 12)*3 + ADCLO)
#define VOLTS2BITS(volts)   (4096/3*(volts - ADCLO))
#define AD_ORIGIN   (2048)

Enumerations

enum  SAMPLING_MODE { CASCADED_MODE = 0, SIMULTANEOUS_MODE = 1 }
 

sampling mode configuration

More...
enum  SEQ_MODE { INDEPENDENT_SEQ_MODE = 0, CASCADED_SEQ_MODE = 1 }
 

sequence mode configuration

More...
enum  SOC_MODE { PWM_SOC = (int)0x8901, GPIO_SOC = 0x0080, SW_SOC = 0x0000 }
 

start of conversion (SOC) configuration

More...
enum  POLARITY { UNIPOLAR = 0, BIPOLAR = 1 }
 

input polarity configuration

More...

Functions

void ConfigureAD (void(*interruptFCN)(void), _iq fAD, Uint16 tSH, SEQ_MODE seqMode, SAMPLING_MODE samplingMode, SOC_MODE socMode, Uint16 offtrim)
void AddChannel (Uint16 input, Uint16 channel, _iq offset, _iq gain)
void AddUnipolarChannel (Uint16 input, Uint16 channel, _iq offset, _iq gain)
void InitAD (void)
 Initializes AD circuits.
void InitADPeripheralClocks (void)
 Initializes AD clock.
static void ReinitADSEQ1 (void)
 Prepare AD SEQ1 for next acquisition: Reset SEQ1, clear INT SEQ1, ACK int to PIE.
static void ReinitADSEQ2 (void)
 Prepare AD SEQ2 for next acquisition: Reset SEQ2, clear INT SEQ2, ACK int to PIE.
static void SetTrigger (void)
 Trigger to enable internal memory writing.
static void ResetTrigger (void)
 Reset trigger for internal memory writing.
static Uint16 ReadADChannelRaw (Uint16 channel)
 Read raw channel (position in CONV).
static Uint16 ReadADInputRaw (Uint16 input)
 Read raw input (physical ADINPUT).
static Uint16 ReadADChannelRawWriteRaw (Uint16 channel)
 Read channel in raw and writes raw values.
static Uint16 ReadADInputRawWriteRaw (Uint16 input)
 Read input in raw and writes raw values.
static _iq ReadADInput (Uint16 input)
 Read channel with specified gain and offset.
static _iq ReadADInputWriteRaw (Uint16 input)
 Read channel with specified gain and offset and write raw to memory.
static void ReadADSimultaneousInputWriteRaw (Uint16 aInput, Uint16 bInput, volatile _iq *aVal, volatile _iq *bVal)
static _iq Bits2Units (Uint16 rawVal, Uint16 input)

Variables

struct ADConfiguration adConfiguration

Detailed Description

AD Routines.

File Name: adc.h Project: TIMotorLIB

TI Doc: SPRU812

Author:
Pablo Garcia (pgarcia@isa.uniovi.es)

This module allows to program the AD converter. Supported functions include the configuration of the channel list, read of values both in raw or physical units and storage of read values in memory.

Date:
2007

Definition in file adc.h.


Define Documentation

#define AD_ORIGIN   (2048)

Definition at line 113 of file adc.h.

#define ADCINA0   0
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 58 of file adc.h.

#define ADCINA1   1
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 59 of file adc.h.

#define ADCINA2   2
#define ADCINA3   3
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 61 of file adc.h.

#define ADCINA4   4
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 62 of file adc.h.

#define ADCINA5   5

Definition at line 63 of file adc.h.

#define ADCINA6   6

Definition at line 64 of file adc.h.

#define ADCINA7   7

Definition at line 65 of file adc.h.

#define ADCINB0   8

Definition at line 66 of file adc.h.

#define ADCINB1   9
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 67 of file adc.h.

#define ADCINB2   10
#define ADCINB3   11
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 69 of file adc.h.

#define ADCINB4   12
Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 70 of file adc.h.

#define ADCINB5   13

Definition at line 71 of file adc.h.

#define ADCINB6   14

Definition at line 72 of file adc.h.

#define ADCINB7   15

Definition at line 73 of file adc.h.

#define BITS2VOLTS ( bits   )     ((bits >> 12)*3 + ADCLO)

Definition at line 109 of file adc.h.

#define CH0_RAW   ((AdcRegs.ADCRESULT0 & 0xFFF0) >> 4)

Definition at line 75 of file adc.h.

#define CH0_RAW_MIRROW   (AdcMirror.ADCRESULT0)

Definition at line 92 of file adc.h.

#define CH10_RAW   ((AdcRegs.ADCRESULT10 & 0xFFF0) >> 4)

Definition at line 85 of file adc.h.

#define CH10_RAW_MIRROW   (AdcMirror.ADCRESULT10)

Definition at line 102 of file adc.h.

#define CH11_RAW   ((AdcRegs.ADCRESULT11 & 0xFFF0) >> 4)

Definition at line 86 of file adc.h.

#define CH11_RAW_MIRROW   (AdcMirror.ADCRESULT11)

Definition at line 103 of file adc.h.

#define CH12_RAW   ((AdcRegs.ADCRESULT12 & 0xFFF0) >> 4)

Definition at line 87 of file adc.h.

#define CH12_RAW_MIRROW   (AdcMirror.ADCRESULT12)

Definition at line 104 of file adc.h.

#define CH13_RAW   ((AdcRegs.ADCRESULT13 & 0xFFF0) >> 4)

Definition at line 88 of file adc.h.

#define CH13_RAW_MIRROW   (AdcMirror.ADCRESULT13)

Definition at line 105 of file adc.h.

#define CH14_RAW   ((AdcRegs.ADCRESULT14 & 0xFFF0) >> 4)

Definition at line 89 of file adc.h.

#define CH14_RAW_MIRROW   (AdcMirror.ADCRESULT14)

Definition at line 106 of file adc.h.

#define CH15_RAW   ((AdcRegs.ADCRESULT15 & 0xFFF0) >> 4)

Definition at line 90 of file adc.h.

#define CH15_RAW_MIRROW   (AdcMirror.ADCRESULT15)

Definition at line 107 of file adc.h.

#define CH1_RAW   ((AdcRegs.ADCRESULT1 & 0xFFF0) >> 4)

Definition at line 76 of file adc.h.

#define CH1_RAW_MIRROW   (AdcMirror.ADCRESULT1)

Definition at line 93 of file adc.h.

#define CH2_RAW   ((AdcRegs.ADCRESULT2 & 0xFFF0) >> 4)

Definition at line 77 of file adc.h.

#define CH2_RAW_MIRROW   (AdcMirror.ADCRESULT2)

Definition at line 94 of file adc.h.

#define CH3_RAW   ((AdcRegs.ADCRESULT3 & 0xFFF0) >> 4)

Definition at line 78 of file adc.h.

#define CH3_RAW_MIRROW   (AdcMirror.ADCRESULT3)

Definition at line 95 of file adc.h.

#define CH4_RAW   ((AdcRegs.ADCRESULT4 & 0xFFF0) >> 4)

Definition at line 79 of file adc.h.

#define CH4_RAW_MIRROW   (AdcMirror.ADCRESULT4)

Definition at line 96 of file adc.h.

#define CH5_RAW   ((AdcRegs.ADCRESULT5 & 0xFFF0) >> 4)

Definition at line 80 of file adc.h.

#define CH5_RAW_MIRROW   (AdcMirror.ADCRESULT5)

Definition at line 97 of file adc.h.

#define CH6_RAW   ((AdcRegs.ADCRESULT6 & 0xFFF0) >> 4)

Definition at line 81 of file adc.h.

#define CH6_RAW_MIRROW   (AdcMirror.ADCRESULT6)

Definition at line 98 of file adc.h.

#define CH7_RAW   ((AdcRegs.ADCRESULT7 & 0xFFF0) >> 4)

Definition at line 82 of file adc.h.

#define CH7_RAW_MIRROW   (AdcMirror.ADCRESULT7)

Definition at line 99 of file adc.h.

#define CH8_RAW   ((AdcRegs.ADCRESULT8 & 0xFFF0) >> 4)

Definition at line 83 of file adc.h.

#define CH8_RAW_MIRROW   (AdcMirror.ADCRESULT8)

Definition at line 100 of file adc.h.

#define CH9_RAW   ((AdcRegs.ADCRESULT9 & 0xFFF0) >> 4)

Definition at line 84 of file adc.h.

#define CH9_RAW_MIRROW   (AdcMirror.ADCRESULT9)

Definition at line 101 of file adc.h.

#define MAX_CH   16

Definition at line 57 of file adc.h.

#define VOLTS2BITS ( volts   )     (4096/3*(volts - ADCLO))

Definition at line 111 of file adc.h.


Enumeration Type Documentation

enum POLARITY

input polarity configuration

Enumerator:
UNIPOLAR 

Unipolar channel.

BIPOLAR 

Bipolar channel.

Definition at line 140 of file adc.h.

sampling mode configuration

Enumerator:
CASCADED_MODE 

AD reads in cascade.

SIMULTANEOUS_MODE 

AD reads simultaneous.

Definition at line 121 of file adc.h.

enum SEQ_MODE

sequence mode configuration

Enumerator:
INDEPENDENT_SEQ_MODE 

Sequencers A/B are independent.

CASCADED_SEQ_MODE 

Sequencers A/B are joined.

Definition at line 127 of file adc.h.

enum SOC_MODE

start of conversion (SOC) configuration

Enumerator:
PWM_SOC 

Start of conversion triggered by PWM.

GPIO_SOC 

Start of conversion triggered by external GPIO.

SW_SOC 

Start of conversion triggered by software.

Definition at line 133 of file adc.h.


Function Documentation

void AddChannel ( Uint16  input,
Uint16  channel,
_iq  offset,
_iq  gain 
)

Add channel to the AD module.

Parameters:
input input number (ADCINA0...ADCINA7, ADCINB0...ADCINB7)
channel set the S/H channel associated to the input.
offset offset in physical units
gain units/bits gain

Definition at line 127 of file adc.c.

void AddUnipolarChannel ( Uint16  input,
Uint16  channel,
_iq  offset,
_iq  gain 
)

Add unipolar channel to the AD module.

Parameters:
input input number (ADCINA0...ADCINA7, ADCINB0...ADCINB7)
channel set the S/H channel associated to the input.
offset offset in physical units
gain units/bits gain

Definition at line 154 of file adc.c.

static _iq Bits2Units ( Uint16  rawVal,
Uint16  input 
) [inline, static]

Convert AD read from bits to units

Parameters:
rawVal read value in bits
input read input
Returns:
value in units

Definition at line 451 of file adc.h.

void ConfigureAD ( void(*)(void)  interruptFCN,
_iq  fAD,
Uint16  tSH,
SEQ_MODE  seqMode,
SAMPLING_MODE  samplingMode,
SOC_MODE  socMode,
Uint16  offtrim 
)

Configure AD module.

Parameters:
interruptFCN pointer to interrupt routine called on A/D finished conversion. If not desired pass NULL.
fAD desired AD clock in Mhz
tSH desired SH acquisition time in ns
seqMode INDEPENDENT_SEQ_MODE or CASCADED_SEQ_MODE.
samplingMode CASCADED_MODE or SIMULTANEOUS_MODE
socMode,: start of conversion modes PWM_SOC (start of conversion by pwm), GPIO_SOC (start of conversion by external GPIO) or SW_SOC (start of conversion by software)
offtrim AD offset compensation

Definition at line 55 of file adc.c.

void InitAD ( void   ) 

Initializes AD circuits.

Definition at line 163 of file adc.c.

void InitADPeripheralClocks ( void   ) 

Initializes AD clock.

Definition at line 176 of file adc.c.

static Uint16 ReadADChannelRaw ( Uint16  channel  )  [inline, static]

Read raw channel (position in CONV).

Read AD channel in raw (bits).

Parameters:
channel channel to be read.
Returns:
raw value (bits)

Definition at line 359 of file adc.h.

static Uint16 ReadADChannelRawWriteRaw ( Uint16  channel  )  [inline, static]

Read channel in raw and writes raw values.

Read AD channel in raw (bits) and write the value to internal memory.

Parameters:
channel channel to be read.
Returns:
raw value (bits)

Definition at line 379 of file adc.h.

static _iq ReadADInput ( Uint16  input  )  [inline, static]

Read channel with specified gain and offset.

Read AD input in units.

Parameters:
input input to be read.
Returns:
readed value in physical units
Examples:
TIMotorLIBExampleSw/main.c.

Definition at line 408 of file adc.h.

static Uint16 ReadADInputRaw ( Uint16  input  )  [inline, static]

Read raw input (physical ADINPUT).

Read AD input in raw (bits).

Parameters:
input input to be read.
Returns:
raw value (bits)

Definition at line 369 of file adc.h.

static Uint16 ReadADInputRawWriteRaw ( Uint16  input  )  [inline, static]

Read input in raw and writes raw values.

Read AD input in raw (bits) and write the value to internal memory.

Parameters:
input channel to be read.
Returns:
raw value (bits)

Definition at line 393 of file adc.h.

static _iq ReadADInputWriteRaw ( Uint16  input  )  [inline, static]

Read channel with specified gain and offset and write raw to memory.

Read AD input in units and write raw (bits) value to internal memory.

Parameters:
input input to be read.
Returns:
readed value in physical units
Examples:
TIMotorLIBExample1/main.c, TIMotorLIBExample2/main.c, TIMotorLIBExample3/main.c, and TIMotorLIBExampleHrdw/main.c.

Definition at line 419 of file adc.h.

static void ReadADSimultaneousInputWriteRaw ( Uint16  aInput,
Uint16  bInput,
volatile _iq *  aVal,
volatile _iq *  bVal 
) [inline, static]

Read two AD simultaneous inputs in units and write raw (bits) value to internal memory.

Parameters:
aInput a input to be read.
bInput b input to be read.
aVal read value for a input in physical units
bVal read value for b input in physical units

Read two simultaneous channel. Input is the first channel. Values are returned on aVal, bVal

Definition at line 434 of file adc.h.

static void ReinitADSEQ1 ( void   )  [inline, static]

Prepare AD SEQ1 for next acquisition: Reset SEQ1, clear INT SEQ1, ACK int to PIE.

Prepare A/D subsystem SEQ1 for a next acquisition. This function must be called after all the readings in the actual sampling period are done.

Examples:
TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 311 of file adc.h.

static void ReinitADSEQ2 ( void   )  [inline, static]

Prepare AD SEQ2 for next acquisition: Reset SEQ2, clear INT SEQ2, ACK int to PIE.

Prepare A/D subsystem SEQ2 for a next acquisition. This function must be called after all the readings in the actual sampling period are done.

Definition at line 322 of file adc.h.

static void ResetTrigger ( void   )  [inline, static]

Reset trigger for internal memory writing.

Set trigger equal 0. It disables internal memory writing of AD read values.

Definition at line 347 of file adc.h.

static void SetTrigger ( void   )  [inline, static]

Trigger to enable internal memory writing.

Set trigger equal 1. It disables internal memory writing of AD read values.

Examples:
TIMotorLIBExample1/main.c, TIMotorLIBExample2/main.c, TIMotorLIBExample3/main.c, TIMotorLIBExampleHrdw/main.c, and TIMotorLIBExampleSw/main.c.

Definition at line 335 of file adc.h.


Variable Documentation

Definition at line 30 of file adc.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines
Generated on Sat Apr 16 11:42:44 2011 for TIMotorLIB by  doxygen 1.6.3