ADC method and global variable - MC9S08QG8

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

ADC method and global variable - MC9S08QG8

1,747 次查看
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 回复数

776 次查看
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 项奖励
回复

776 次查看
neocronos
Contributor III
:smileyvery-happy: My mistake. Thanks!!
0 项奖励
回复