<< Chapter < Page Chapter >> Page >

The callback function template

void process(Int16 *r_data, Int16 *w_data {/* Processing functions (user-defined) */ }

Using the driver in the ccs environment

In this section we will describe the way the driver is used in the CCS environment.

  1. Create a new project in the CCS environment
  2. Copy the following files to the project directory This is not mandatory. You may add the files from any directory. :
  • aic24.c
  • aic24.h
  • aic24_defs.h
  • AIC24-C6713.cdb
  • Add aic24.c and AIC24-C6713.cdb files to your project.
  • Add the user file with the callback function.

An example of this process is provided in the next section.

An example

The example creates two audio paths as follows:

Path # 1: J14 ⇒ CODEC#0/INP1 ⇒ SMARTDM/Channel 0 ⇒ McBSP1/Channel 0 ⇒ DSP ⇒ McBSP1/Channel 2 ⇒ SMARTDM/Channel 2 ⇒ CODEC#2/OUTP1 ⇒ J4

Path # 2: J13 ⇒ CODEC#2/INP3 ⇒ SMARTDM/Channel 2 ⇒ McBSP1/Channel 2 ⇒ DSP ⇒ McBSP1/Channel 0 ⇒ SMARTDM/Channel 0 ⇒ CODEC#0/OUTP2 ⇒ J5

The example is illustrated in Figure 9. A user defined function “test.c” was created for this application.

CCS Example Configuration

The program

The first part of the program defines the buffers for reading and writing samples.

Buffer allocation

#define NUM_CODECS 4 // The number of CODECs connected #define DATANUM 128 // The number of samples in each channel#define DATAMODE 0 // AIC24 operates in data mode #if 〔DATAMODE == 1〕#define BUFS_PER_CHANNEL 1 #else#define BUFS_PER_CHANNEL 2 #endifInt16 r_data1[DATANUM*NUM_CODECS*BUFS_PER_CHANNEL]; // data buffer for readInt16 w_data1[DATANUM*NUM_CODECS*BUFS_PER_CHANNEL]; // data buffer for readInt16 r_data2[DATANUM*NUM_CODECS*BUFS_PER_CHANNEL]; // data buffer for writeInt16 w_data2[DATANUM*NUM_CODECS*BUFS_PER_CHANNEL]; // data buffer for write

The callback function follows the template introduced in the previous section, and calls the subroutine “copyData”.

The callback function

void copyData〔Int16 *inbuf, Int16 *outbuf, Int16 length〕 {Int16 i = 0;for 〔i = 0; i<length; i++rbbrk; { outbuf[i]= inbuf[i];} }// The callback function that is called when the EDMA buffers are full // The function copies the data from channel 0 to channel 2void process(Int16 *r_data, Int16 *w_data) {if (hAIC24.DataMode) {int i; for (i=0; i<DATANUM; i++) r_data[0*DATANUM+i]⩓= 0xfffe; }copyData(r_data+0*DATANUM, w_data+2*DATANUM, DATANUM); }

The main program:

  • Sets the AIC24 handle
  • Maps the analog ports The driver sets a default configuration. Those commands are needed if changes in the default configuration are required.
  • Starts the AIC24

After this step, the program will enter in an endless loop. Samples will be processed each time an EDMA interrupt occurs.

The “main” program

int main() {// setting up the AIC24 handle AIC24_InitDefaults(⩓hAIC24, NUM_CODECS, DATANUM, r_data1, r_data2, w_data1, w_data2, process);// determining data mode (continuous or programming) hAIC24.DataMode = DATAMODE;// example for setting devices input and outputs // if defaults are ok then this is not necessaryhAIC24.Regs[0].creg6.reg6a.control_bit.mici = 0;hAIC24.Regs[0].creg6.reg6a.control_bit.inp1 = 1;hAIC24.Regs[0].creg6.reg6a.control_bit.inp2 = 0;hAIC24.Regs[0].creg6.reg6a.control_bit.inp3 = 0;hAIC24.Regs[0].creg6.reg6a.control_bit.inp4 = 0;hAIC24.Regs[0].creg6.reg6b.control_bit.outp1 = 0;hAIC24.Regs[0].creg6.reg6b.control_bit.outp2 = 1;hAIC24.Regs[0].creg6.reg6b.control_bit.outp3 = 0;hAIC24.Regs[1].creg6.reg6a.control_bit.mici = 0;hAIC24.Regs[1].creg6.reg6a.control_bit.inp1 = 0;hAIC24.Regs[1].creg6.reg6a.control_bit.inp2 = 0;hAIC24.Regs[1].creg6.reg6a.control_bit.inp3 = 0;hAIC24.Regs[1].creg6.reg6a.control_bit.inp4 = 0;hAIC24.Regs[1].creg6.reg6b.control_bit.outp1 = 0;hAIC24.Regs[1].creg6.reg6b.control_bit.outp2 = 0;hAIC24.Regs[1].creg6.reg6b.control_bit.outp3 = 0;hAIC24.Regs[2].creg6.reg6a.control_bit.mici = 0;hAIC24.Regs[2].creg6.reg6a.control_bit.inp1 = 0;hAIC24.Regs[2].creg6.reg6a.control_bit.inp2 = 0;hAIC24.Regs[2].creg6.reg6a.control_bit.inp3 = 1;hAIC24.Regs[2].creg6.reg6a.control_bit.inp4 = 0;hAIC24.Regs[2].creg6.reg6b.control_bit.outp1 = 1;hAIC24.Regs[2].creg6.reg6b.control_bit.outp2 = 0;hAIC24.Regs[2].creg6.reg6b.control_bit.outp3 = 0;hAIC24.Regs[3].creg6.reg6a.control_bit.mici = 0;hAIC24.Regs[3].creg6.reg6a.control_bit.inp1 = 0;hAIC24.Regs[3].creg6.reg6a.control_bit.inp2 = 0;hAIC24.Regs[3].creg6.reg6a.control_bit.inp3 = 0;hAIC24.Regs[3].creg6.reg6a.control_bit.inp4 = 0;hAIC24.Regs[3].creg6.reg6b.control_bit.outp1 = 0;hAIC24.Regs[3].creg6.reg6b.control_bit.outp2 = 0;hAIC24.Regs[3].creg6.reg6b.control_bit.outp3 = 0;// Starting the AIC24 AIC24_Start(⩓hAIC24);

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, From matlab and simulink to real-time with ti dsp's. OpenStax CNX. Jun 08, 2009 Download for free at http://cnx.org/content/col10713/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'From matlab and simulink to real-time with ti dsp's' conversation and receive update notifications?

Ask