beautypg.com

12 µ vision 2 debug program example – Texas Instruments MSC1210 User Manual

Page 266

background image

mVision 2 Debug Program Example

17-38

17.12

µ

Vision 2 Debug Program Example

SIGNAL void spi_sim (void)

{

/*This program runs in parallel with the main program.

It sends out a character byte whose value is post incremented at the end of
each associated time lapse.

SPI_IN is the portal through which the byte data is sent to the main program.
In addition, the data transmitted from the main program is received at the
portal, SPI_OUT*/

int j;

j = 0x21; //initialize byte data value to be transmitted

spi_in = j;

//send byte data

twatch (100); //idle 100 clock cycles

while (1) //start infinite loop

{

twatch (50);

j++;

//increment value of byte data to be transmitted

spi_in = j;

//transmit another byte of data

twatch (97);

//wait 97 clock cycles

/*data transmitted from main program has been receive in portal SPI_OUT

automatically. Its value is displayed in the Command Line display area*/

printf (”\nSPI_OUT = %d”, spi_out);

j++;

/*send another incremented data byte, and receive and display a new data

byte transmitted from main.*/

spi_in = j;

twatch (116);

printf (”\nSPI_OUT = %d”, spi_out);

}

}

The data received from the

µ

Version 2 debug program, by the main SPI pro-

gram is written to the Serial #1 window. A snapshot of this window is included
in Figure 17−17.