ADC method and global variable - MC9S08QG8

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

ADC method and global variable - MC9S08QG8

1,744件の閲覧回数
neocronos
Contributor III
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:

Code:
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:

Code:
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?

Thanks


Added p/n to subject.


Message Edited by NLFSJ on 2008-05-21 10:26 PM
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

773件の閲覧回数
allawtterb
Contributor IV
You declared medsensor as a single byte but you are trying to put 4 bytes in it.  You need to declare medsensor as an array and pass the array.
Code:
void TI1_OnInterrupt(void){ byte medsensor[4];  bool waitformed;  waitformed = 1;      adc_Measure(waitformed);  adc_GetValue8(medsensor);    flag = 'Z';}

 


Message Edited by allawtterb on 2008-05-20 03:32 PM
0 件の賞賛
返信

773件の閲覧回数
neocronos
Contributor III
:smileyvery-happy: My mistake. Thanks!!
0 件の賞賛
返信