Rolf Buchholz - 2008-05-02

Hello,

i have following code-snipsed create and get a mistery error.
If i only compile the "Master Range", the ADDAT Value is 12.
If i include the "Slave Range", the ADDAT Value for the Master Range change to 9.
The ADDAT Value of the Slave Range is ok.

What is wrong?

Rolf

########################################################################
void AD_test()
{
char zeile2[21]={"U = 0,000V          "};
char zeile3[21]={"U = 0,0000V         "};
char zeile4[21]={"DAPR =              "};
char DAPR_Array[8] = { 0x40,0x51,0x73,0x95,0xB7,0xD9,0xFB,0x0C};
unsigned int z;
char ADDATg ;
char ADDATf;

// ####### Master Range #######
ADCON0 = 0x00;
DAPR = 0x00; // Start Wandlung
while( ADCON0 & 0x10);

z = ADDAT; ADDATg = ADDAT;

zeile2[8]=(z*195/10) % 10 + 0x30; // 3. NK
zeile2[7]=(z*195/100) % 10 + 0x30;  // 2. NK
zeile2[6]=(z*195/1000) % 10 + 0x30;  // 1. NK
zeile2[4]=(z*195/10000) % 10 + 0x30; // VK

zeile4[9]=(ADDATg/1) % 10 + 0x30;
zeile4[8]=(ADDATg/10) % 10 + 0x30;
zeile4[7]=(ADDATg/100) % 10 + 0x30;
// ####### Maste Range End #######

// ####### Slave Range #######
ADCON0 = 0x00;
DAPR = DAPR_Array[ADDATg/32];
while( ADCON0 & 0x10);
z = ADDAT; ADDATf = ADDAT;

zeile3[9]=(z*244/5) % 10 + 0x30; // 4. NK
zeile3[8]=(z*244/50) % 10 + 0x30; // 3. NK
zeile3[7]=(z*244/500) % 10 + 0x30;  // 2. NK
zeile3[6]=(z*244/5000) % 10 + 0x30;  // 1. NK
zeile3[4]=(z*244/50000) % 10 + 0x30; // VK

zeile4[14]=(ADDATf/1) % 10 + 0x30; 
zeile4[13]=(ADDATf/10) % 10 + 0x30;
zeile4[12]=(ADDATf/100) % 10 + 0x30;
// ####### Slave Range end #######

LCD_command(LCD_CMD_ROW1);
LCD_puts("  AD-Wandler Test  ");
LCD_command(LCD_CMD_ROW2);
LCD_puts(zeile2);
LCD_command(LCD_CMD_ROW3);
LCD_puts(zeile3);
LCD_command(LCD_CMD_ROW4);
LCD_puts(zeile4);
}