Alejandro Bermudez

ADC method and global variable - MC9S08QG8

Discussion created by Alejandro Bermudez on May 20, 2008
Latest reply on May 22, 2008 by Alejandro Bermudez
Hello, I'm working with the MC9S08QG8 and the Processor Expert of the Codewarrior 5.9. I have an ADC bean and I'm using Measure and GetValue8 methods inside a time interrupt:

void TI1_OnInterrupt(void){ byte medsensor;  bool waitformed;  waitformed = 1;      adc_Measure(waitformed);  adc_GetValue8(&medsensor);    flag = 'Z';}

 ... and for some weird reason, the global variable flag doesn't keep that 'Z' value, once the program returns to the main, the flag changes it's value to what it had before. I found that making GetValue8 comment (with //) the global variable flag kept the 'Z' value.

GetValue8 code is just:

byte adc_GetValue8(byte *Values){  if (!OutFlg) {                       /* Is output flag set— */    return ERR_NOTAVAIL;               /* If no then error */  }  Values[0] = adc_OutV[0];             /* Save measured values to the output buffer */  Values[1] = adc_OutV[1];             /* Save measured values to the output buffer */  Values[2] = adc_OutV[2];             /* Save measured values to the output buffer */  Values[3] = adc_OutV[3];             /* Save measured values to the output buffer */  return ERR_OK;                       /* OK */}

Does someone know what is happening?


Added p/n to subject.

Message Edited by NLFSJ on 2008-05-21 10:26 PM