/*========================================================================*/ /* Standard header files for initialization of the libraries and /* initialization routines for the program */ /*========================================================================*/ /*========================================================================*/ /* These header files can be found in C:\UTIL.DSP */ /*========================================================================*/ #include "bus.h" #include "serial.h" #include "timers.h" #include "aic.h" /* MACROS and STRUCTURES for AIC */ /*========================================================================*/ /* Standard header files used for various tasks in the program */ /*========================================================================*/ #include #include #include #include /*========================================================================*/ /* Proto-types of Initialization Procedures */ /*========================================================================*/ void init_c30bus(void); void init_aic(void); /*========================================================================*/ /* INIT_C30BUS(): INITIALIZE TMS320C30 BUS WAIT STATES AND TURN ON CACHE */ /* Uses functions from C:\UTIL.DSP\BUS.LIB */ /*========================================================================*/ void init_c30bus(void) { pri_wait(0); /* 0 wait states on primary bus */ exp_wait(0); /* 0 wait states on expansion bus */ cache_on(); /* enable instruction cache */ } /*========================================================================*/ /* INIT_AIC(): INITIALIZE TMS320C30 TIMER 0 AND SERIAL PORT 0 FOR */ /* COMMUNICATION WITH AIC. INITIALIZE AIC PARAMETERS. */ /* NOTE: i IS A VOLATILE TO FORCE TIME DELAYS AND TO FORCE */ /* READS OF SERIAL PORT DATA RECEIVE REGISTER TO CLEAR */ /* THE RECEIVE INTERRUPT FLAG */ /*========================================================================*/ void init_aic(void) { volatile int i; /*--------------------------------------------------------------------*/ /* SET AIC CONFIGURATION CHIP */ /* 1. ALLOW 8 KHZ SAMPLING RATE AND 3.6 KHZ ANTIALIASING FILTER */ /* GIVEN A 7.5 MHZ MCLK TO THE AIC FROM A 30 MHZ TMS320C30 */ /* 2. ENABLE A/D HIGHPASS FILTER */ /* 3. SET SYNCHRONOUS TRANSMIT AND RECEIVE */ /* 4. ENABLE SINX/X D/A CORRECTION FILTER */ /* 5. SET AIC FOR +/- 1.5 V INPUT */ /*--------------------------------------------------------------------*/ aic_command_0.command = 0; /* SETUP AIC COMMAND WORD ZERO */ aic_command_0.ra = 13; /* ADJUST SAMPLING RATE TO 8 kHz */ aic_command_0.ta = 13; /* AND 3.6 kHz ANTIALIAS FILTER */ aic_command_1.command = 1; /* SETUP DEFAULT AIC COMMAND WORD 1 */ aic_command_1.ra_prime = 1; aic_command_1.ta_prime = 1; aic_command_1.d_f = 0; aic_command_2.command = 2; /* SETUP DEFAULT AIC COMMAND WORD 2 */ aic_command_2.rb = 36; aic_command_2.tb = 36; aic_command_3.command = 3; aic_command_3.highpass = ON; /* TURN ON INPUT HIGHPASS FILTER */ aic_command_3.loopback = OFF; /* DISABLE AIC LOOPBACK */ aic_command_3.aux = OFF; /* DISABLE AUX INPUT */ aic_command_3.sync = ON; /* ENABLE SYNCHRONOUS A/D AND D/A */ aic_command_3.gain = ONEp5_V; /* SET FOR 1.5 v p-p INPUT */ /* USE THREE_V for 3 v p-p INPUT */ aic_command_3.sinx = ON; /* ENABLE SIN x/x CORRECTION FILTER */ /*--------------------------------------------------------------------*/ /* CONFIGURE TIMER 0 TO ACT AS AIC MCLK */ /* THE TIMER IS CONFIGURED IN THE FOLLOWING WAY */ /* 1. THE TIMER'S VALUE DRIVES AN ACTIVE-HIGH TCLK 0 PIN */ /* 2. THE TIMER IS RESET AND ENABLED */ /* 3. THE TIMER'S IS IN PULSE MODE */ /* 4. THE TIMER HAS A PERIOD OF TWO INSTRUCTION CYCLES */ /*--------------------------------------------------------------------*/ t0_period(1); /* In C:\UTIL.DSP\TIMERS.LIB */ t0_init(); /* In C:\UTIL.DSP\TIMERS.LIB */ /*--------------------------------------------------------------------*/ /* CONFIGURE SERIAL PORT 0 */ /* 1. EXTERNAL FSX, FSR, CLKX, CLKR */ /* 2. VARIABLE DATA RATE TRANSMIT AND RECEIVE */ /* 3. HANDSHAKE DISABLED */ /* 4. ACTIVE HIGH DATA AND CLK */ /* 5. ACTIVE LOW FSX,FSR */ /* 6. 16 BIT TRANSMIT AND RECEIVE WORD */ /* 7. TRANSMIT INTERRUPT */ /* 8. RECEIVE INTERRUPT ENABLED/RECEIVE */ /* 9. FSX, FSR, CLKX, CLKR, DX, DR CONFIGURED AS SERIAL */ /* PORT PINS */ /*--------------------------------------------------------------------*/ p0_init(); /* In C:\UTIL.DSP\SERIAL.LIB. Initializes */ /* Serial Port 0 to the above state */ asm(" LDI 2,IOF"); /* RESET AIC BY PULLING XF0 ACTIVE-LOW */ for(i = 0; i < 50; i++); /* KEEP RESET LOW FOR SOME PERIOD OF TIME */ p0_reset(); /* In C:\UTIL.DSP\SERIAL.LIB. Reset and */ /* start Serial Port 0. */ p0_transmit(0); /* In C:\UTIL.DSP\SERIAL.LIB. Load Serial*/ /* Port 0 transmitter with 0 using non- */ /* polling function to make sure first */ /* word sent to AIC is not a command. */ p0_receive(); /* In C:\UTIL.DSP\SERIAL.LIB. Enable */ /* receive on Serial Port 0. */ asm(" LDI 6,IOF"); /* PULL AIC OUT OF RESET */ /*--------------------------------------------------------------------*/ /* MODIFY AIC CONFIGURATION */ /*--------------------------------------------------------------------*/ p0_xmit(3); /* In C:\UTIL.DSP\SERIAL.LIB. Notify AIC */ /* that next word will be a command. */ p0_xmit(*((int *) &aic_command_0)); /* Init TA and RA registers. */ /* Note: aic_command_1 and 2 are set to the correct values when the */ /* AIC is reset since they are the default AIC reset values. */ p0_xmit(3); /* Notify AIC next word is a command. */ p0_xmit(*((int *) &aic_command_3)); /* Init AIC control register */ }