| The first
statement added to the main.c file is char
sstr[40]. This declares an area
in RAM where we can store the string that we want to
send. It is delared type char
(character) and is an array of 40 elements. The square
brackets with the value in it denotes sstr as an
array.
Next, the serial port needs initialization and the
statement SetupCommPort(
BAUD9600 ) does this.
The statement
strcpy( sstr, "Hello World!" );
uses the library function strcpy (string copy) to copy
the "Hello World!" character string into the
sstr character array. |
char
sstr[40];
void main( void )
{
init();
counter = 0;
TRISC &= ~BIT2;
SetupCommPort( BAUD9600 );
strcpy( sstr, "Hello World!");
CommPortSendString( sstr );
while( 1 )
{
PORTC = 0b00000100;
delay_msec( 50 );
PORTC = 0b00000000;
delay_msec( 50 );
}
} |