Texas Instruments MSC1210 User Manual

Page 265

Advertising
background image

Serial Peripheral Interface (SPI)

17-37

Keil Simulator

if (AISTAT & 0x04)

{/*Receiver*/

i = SPIRCON & 0x7F; //extract the count for the number of

AISTAT &= ~0x04; //deactivate SPI receive flag

if (l >= 50)

{

/*do not exceed the 50 received_data[] array limit*/

for (l = 0; l < 5; l++)

{

printf (”\n”);

for (k = 0; k < 10; k++)

{

printf (” %c”, received_data[k + l * 10] );

}

}

printf (”\n”);

l=0;

//reset the received_data[] array index.

}

for (k = 0; k < i; k++)

{

if (l >= 50)

break;

/*data received through the SPI channel is read at the SPIDATA SFR*/

received_data[l++] = SPIDATA; //keep track of received data

}

}

}

void main(void)

{

setport ();

init_spi ();

test_spi ();

}

In addition to the main simulation program, a

µ

Vision 2 debugging program

was also written to supply the received data to the test simulation program.
This

µ

Vision program transmits and receives data at periodic intervals from the

main program. The SPI communication protocol is used for this data transfer.
The

µ

Version 2 debug program behaves as the slave, while the main program

is the master. The debug program is presented and explained in the following
section.

Advertising