Texas Instruments MSC1210 manual Manual Summation Mode, ADC Summation Mode

Models: MSC1210

1 324
Download 324 pages 20.97 Kb
Page 154
Image 154

Summation/Shifter Register

12.13.1 Manual Summation Mode

The first mode of operation, manual summation, allows you to quickly add 32-bit values. In this mode, your program simply write the values to be added to the SUMR0, SUMR1, SUMR2, and SUMR3 SFRs. When a value is written to SUMR0, the current value of SUMR0-3 will be added to the summation register. For example, the following code will add 0x00123456 to 0x0051AB04:

SSCON = 0x00; // Clear summation register, manual summation

SUMR3 = 0x00; // High byte of 0x00123456

SUMR2 = 0x12; // Next byte of 0x00123456

SUMR1 = 0x034; // Next byte of 0x00123456

SUMR0 = 0x56; // Next byte of 0x0012345 – Perform addition

SUMR3 = 0x00; // High byte of 0x0051AB04

SUMR2 = 0x51; // Next byte of 0x0051AB04

SUMR1 = 0xAB; // Next byte of 0x0051AB04

SUMR0 = 0x04; // Next byte of 0x0051AB04 – Performs addition

ANSWER = (SUMR3 << 24) + (SUMR2 << 16) + (SUMR1 << 8) + SUMR0;

The previous code, although certainly more verbose than a simple ANSWER = 0x00123456 + 0x0051AB04 instruction in ‘C’, is much, much faster when analyzed in assembly language. In assembly language, the above solution requires just four MOV instructions for each summation, whereas the simple addition approach (which does not take advantage of the MSC1210 summation register) takes at least 8 MOV instructions and 4 ADD instructions.

12.13.2 ADC Summation Mode

The ADC summation mode functions very similarly to the manual summation mode, but instead of your program writing values to the SUMRx registers, the ADC writes values to the SUMRx registers.

In this mode, the CNT bits of SSCON are set to indicate how many ADC conversions should be summed in the summation register. The ADC will then deliver the requested number of results to the summation register and trigger a summation auxiliary interrupt, if enabled (see Chapter 10, Interrupts).

SSCON = 0x00; // Clear summation register, manual summation SSCON = 0x50; // ADC summation, 8 samples from ADC while(! (AISTAT & 0x40)); // Wait for 8 samples to be added SUM = (SUMR3 << 24) + (SUMR2 << 16) + (SUMR1 << 8) + SUMR0;

The previous code first clears the summation registers by setting SSCON to 0, and then sets SSCON to ADC summation and requests that eight samples from the ADC be summed. The while() loop then waits for the summation auxil- iary interrupt flag to be set, which indicates the requested operation was com- plete. The final line then takes the four individual SFRs and calculates the total summation value.

12-18

Page 154
Image 154
Texas Instruments MSC1210 manual Manual Summation Mode, ADC Summation Mode