TCPmaker : Visual Tour    How Variables and Controls Work Together  

What you DO have to write code for, is to actually do something with the data when it arrives at the micro device. 

In the case of our Pushbutton control associated with Integer variable D1, TCPmaker will generate an Event Handler in your micro code, which is just a little routine that is called whenever that variable is sent from the PC.

TCPmaker cannot know in advance what sort of hardware you may have on your board design, so it leaves this routine empty, so you can fill it in with code that is appropriate. (Hey, we had to leave you something to do!)

Here's what you might add to your micro code in this case (your code shown in boldface type):

// Event handler for variable: D1 - Diode D1 connected to RJ7
void eventD1(void)
{
  // Variable has just arrived, so add your code
  //to DO something with it here:
  LED0_IO = D1;


Note: LED0_IO has been #defined in file HardwareProfile.h of the project as:

#define LED0_IO    (PORTJbits.RJ0)

All you had to do was to add 1 line of code to light up the LED, by just assigning to its port pin the variable that was just sent from the PC.  That's the power of TCPmaker!


 

 
  

5 of 12
Copyright Notice and Author Information