<< 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

how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
what is inflammation
Shelly Reply
part of a tissue or an organ being wounded or bruised.
Wilfred
what term is used to name and classify microorganisms?
Micheal Reply
Binomial nomenclature
adeolu
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