Appendix

More documentation is available at Circuit Cellar Renesas Design Contest 2005 and in the January 2007 issue of Circuit Cellar (#198)

Photos

Click for 
	larger Image Click for larger 
	Image
Photo 12 The actual baudrate measured display mode. CLICK TO ZOOM Photo 13 The event count display mode. CLICK TO ZOOM

Schematics

Figure 1 Schematic diagram for Quickcoms. A PDF version is available here

Listing 3: Connection checking routine from the main.c file

/*****************************************************************************

Name:     configurePins      

Parameters: none                     

Returns:  none      

Description: Checks the analog levels of rs232 pins to decide which are

TXD and RXD pins on each connector.

**************************************************************************** */ 

void configurePins(void)

{

int f2=512;

int f3=512;

int m2=512;

int m3=512;

cables =0;


while (cables==0){


// disable trancievers

DDR_ENFA = 1;

DDR_ENFB = 1;

DDR_ENMA = 1;

DDR_ENMB = 1;

ENFA = FALSE;

ENFB = FALSE;

ENMA = FALSE;

ENMB = FALSE;


//setup ADC

adcon0 = 0x90;

      /*

        10010000;  ** Repeat sweep mode 0, soft trigger, fAD/2

    ||||||||______Analog input select bit 0

    |||||||_______Analog input select bit 1

    ||||||________Analog input select bit 2

    |||||_________A/D operation mode select bit 0

    ||||__________A/D operation mode select bit 1

    |||___________Trigger select bit

    ||____________A/D conversion start flag

    |_____________Frequency select bit 0 */


adcon1 = 0x3A;

      /*

      00111010; ** Scan AN0-AN%, 10-bit mode, fAD/2, Vref connected

    ||||||||______A/D sweep pin select bit 0

    |||||||_______A/D sweep pin select bit 1

    ||||||________A/D operation mode select bit 1

    |||||_________8/10 bit mode select bit

    ||||__________Frequency select bit 1

    |||___________Vref connect bit

    ||____________External op-amp connection mode bit 0

    |_____________External op-amp connection mode bit 1 */   


adcon2 = 0x01;

      /*

      00000001; ** Sample and hold enabled, fAD/2

    ||||||||______AD conversion method select bit

            |||||||_______AD input group select bit 0

      ||||||________AD input group select bit 1

      |||||_________Reserved

      ||||__________Frequency select bit 2

      |||___________Reserved

      ||____________Reserved

      |_____________Reserved */


    adst = 1; // Start a conversion here


    while (adst); // wait for conversions to be done.


 

f2= AN_F2 & 0x03ff; // Mask off the upper 6 bits of the 

// variable leaving only the result

// in the variable itself


f3= AN_F3 & 0x03ff; // Mask off the upper 6 bits of the 

// variable leaving only the result

// in the variable itself


m2= AN_M2 & 0x03ff; // Mask off the upper 6 bits of the 

// variable leaving only the result

// in the variable itself


m3= AN_M3 & 0x03ff; // Mask off the upper 6 bits of the 

// variable leaving only the result

// in the variable itself

// enable correct trancievers by looking for negative voltages

if (f2>VOLTAGE_232){ // 573 = ((-3V/-10 + 2.5V)/ 5V )* 1023 

DisplayString(LCD_LINE2 ,"DB9F    ");

ENFA = TRUE;

ENFB = FALSE;

VoltageF = (f2-512) ;

}else if  (f3>VOLTAGE_232){

DisplayString(LCD_LINE2 ,"DB9F Xvr");

ENFA = FALSE;

ENFB = TRUE;

VoltageF = (f3-512);

}else{ // no DB9F Detected

//DisplayString(LCD_LINE2 ,"No DB9F ");

}


if (m2>VOLTAGE_232){

DisplayString(LCD_LINE1, "DB9M    ");

ENMA = FALSE;

ENMB = TRUE;

VoltageM = (m2-512) ;

}else if (m3>VOLTAGE_232){

DisplayString(LCD_LINE1, "DB9M Xvr");

ENMA = TRUE;

ENMB = FALSE;

VoltageM = (m3-512) ;

}else{ // no DB9M Detected

//DisplayString(LCD_LINE1, "No DB9M ");

}


// check number of cables and setup interrupts accordingly.

cables = (char) (ENFA + ENFB + ENMA + ENMB);

switch (cables){

case 0:

DisplayString(LCD_LINE1 ,"No cable");

DisplayString(LCD_LINE2, "detected");

int_init(0);

break;

case 1:

if (ENFA+ENFB){ // DB9F

int_init(2);

}else{ // DB9M

int_init(1);

}

break;

case 2:

int_init(2); // DB9F by default

break;

}

}

// while(!S2);


}