C– – Efficiency

playing. In some cases speech files can be played to debounce keys. This is why there is no delay in the main() function. Pressing SW2 calls a function, but the switch will not be read again until the time has been spoken so there is no need for a delay there.

Example 5–3. Third Project (C–– with an LCD)

The main difference between this project and the second project is the addition of an LCD display. The variables storing the time were also changed to an array of ints instead of separate int variables to demonstrate the use of C–– arrays. This is not the clearest or easiest way to keep track of the time. It was added as an example of C–– arrays. Multidimensional arrays are not supported in C––, but the same functionality can be achieved by multiplying and adding the indices. For example, if an array is defined as:

int a [3*4]; // equivalent to int a [3][4] in C

Then the element at row x column y can be accessed by using index = rowNum * row + column.

value = a[3*1+0]; //-equivalent to value = a[1][0] in C

[Root]

cmm1.asm cmm1_ram.irx flags.irx main.cmm main.irx main_ram.irx mainasm.asm vroncof2.asm

Jrtc.rpj H[dsp]

[celp]

celp.irx

H celp4.obj [common]

util.obj

H util2.obj [general]

dsp_var.irx dsputil.asm getbits.asm speak.asm speak.irx

H spk_ram.irx [melp]

5-52

Page 348
Image 348
Texas Instruments MSP50C6xx manual Example 5-3. Third Project C-- with an LCD, Celp Celp.irx