TCPmaker : Visual Tour    Sending Messages to Screen Controls  

Since we use the pot on the demo board for various things on various pages, we also enable the optional function sendPotValue() in file mtGen.c.

The C18 code for this function is shown below. The boldface type shows the one extra line we added, which calls a new function HandlePot1():

void sendPotValue(void)
{
  // AN0 should already be set up as an analog input for PICDEM.net2
  ADCON0 = 0x09;  // ADON, Channel 2
  ADCON0bits.GO = 1;

    // Wait until A/D conversion is done
    while(ADCON0bits.GO);

  // AD converter errata work around (ex: PIC18F87J10 A2)
  #if !defined(__18F87J50) && !defined(_18F87J50)
    PRODL = ADCON2;
    ADCON2bits.ADCS0 = 1;
    ADCON2bits.ADCS1 = 1;
    ADCON2 = PRODL;
  #endif

  Pot1 = ADRES;
  Pot1TxFlag = 1;

  HandlePot1();
}  // sendPotValue()

 

 
  

30 of 33
Copyright Notice and Author Information