Example code 7.1 – Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual
Page 74
CHAPTER 7 • SERIAL PORTS 73
Chapter 8 contains information on how to set up a message watch list to monitor the virtual
buffer for selected protocol messages. The Click 500 serial message support function library
helps further automate receive handling. If you want to retrieve the data using the timer
interrupt, but do not want to use the Click serial message support functions, you will need
to write your own parser that uses ClickSerialVPortRxBufferRetrieve. This function has the
same parameters as ClickSerialPortReceive, but should not be used with the CLICK_SE-
RIAL_LIB_NOUSE_TIMER_LIB directive defined.
Example Code 7.1
Example code 7.1 can be found in the Examples > Ch 7 folder and is named
“ExampleCode7.1.c.” The purpose of this example is to demonstrate how to configure and
connect serial ports to virtual ports and how to transmit and receive data. The two modes
used in this example set up the serial to virtual port connections differently to show the
flexibility of the serial ports. Mode1 transmits a message on both virtual port one and two
if the button is pressed; Mode2 listens for up to 29 bytes of data to come in on virtual port
one and then prints the received bytes.
///////////////////////////////////////////////////////////////
// ExampleCode7.1.C
///////////////////////////////////////////////////////////////
#use click500menu.lib
#use click500timer.lib
#use click500serial.lib
#define CLICK_SERIAL_LIB_NOUSE_TIMER_LIB
void Mode1( void );
void Setup1( void );
void Mode2( void );
void Setup2( void );
void main( void )
{
ClickMenuAddMode( Mode1, Setup1, BLUE, 0, 0 );
ClickMenuAddMode( Mode2, Setup2, GREEN, 0, 0 );
ClickMenuStart();
}
void Mode1( void )
{