CW8/DemoBoard56F8357/ProcessorExpert - ADC code problem

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

CW8/DemoBoard56F8357/ProcessorExpert - ADC code problem

3,305 次查看
howdeterminepwm
Contributor I
HI,
I am having one problem in my code for ADC. My Events.c
IRQB:
Code:
#pragma interrupt called /* Comment this line if the appropriate 'Interrupt preserve registers' property */                         /* is set to 'yes' (#pragma interrupt saveall is generated before the ISR)      */void BTB_OnInterrupt(void){   ADCA__Enable();   ADCA__EnableEvent();}

ADCA__OnEnd:
Code:
void ADCA__OnEnd(void){ byte store;   word valores[8];   word threshold = 16384; //32768/2 (Max_ADC_Resolution_divided_by_two)   //==============================    Frac16  canal0,     canal1,     canal2,     canal3;      store = ADCA__GetValue16(valores);      canal0 = (Frac16)((long)valores[0] - 32768);   canal1 = (Frac16)((long)valores[1] - 32768);   canal2 = (Frac16)((long)valores[2] - 32768);   canal3 = (Frac16)((long)valores[3] - 32768);   if(canal0 < threshold)   {    led3_NegVal();   }   else   {    led5_NegVal();   }}

Nothing occur in leds 3 or five, i used ADCA__Measure() in IRQB, debug stop in Measure and not read values.... What my code error??? Some example of how use adc?? Thank you!

 

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

992 次查看
trytohelp
NXP Employee
NXP Employee
Hi,
 
All examples we've are delivered on the installation.
Please have a look to the folder:
  \Stationery\Processor_Expert_Examples\DemoApplications\HWBeans\56F83xx\
 
There are other examples using the ADC bean on the installation.
Please have a look to the example:
  \Stationery\Processor_Expert_Examples\DemoApplications\MotorControl\56F8357\3_BLDC_Quadrature_Encoder
This example refers to a pdf explaining it: TM_bldc_encoder.pdf
 
Hope this will help you.
Pascal
0 项奖励
回复

992 次查看
howdeterminepwm
Contributor I
Hi all,
I am having reopen this post, because new problem  in adc. My problem isn't in read adc's, my code read adc and send value to global variable, one struct, for rs232 i request the read value of adc. I always receive the value equal in all requestions, for example 0x00 + 0x08, two bytes, because read value is 16 bits. I modifed the resistor connected in adc and the value read is 0x00 +  0x08,  my  led on/off because the modify of resistor variable. My code is:
Code:
void AD1_OnEnd(void){/*########### Variaveis internas da função ############*/ byte store, i = 0, j =0, k; word valores[8]; word threshold = 16384; //(32768/2) Metade da resolução total do ADC Frac16 canal[8];/*######################################################*/ store = AD1_GetValue16(valores); if(store == ERR_OK) { /* Armazena os valores lidos dos adc's no vetor canal */  for(k = 0; k < 8; k++)  {   canal[k] = (Frac16)((long)valores[k] - 32768);  }  // /* Coloca os valores no struct global pacote */   for (j = 0; j < 8; j++)  {   pct.ad1_canalValores[i] = (byte)canal[j];   pct.ad1_canalValores[i++] = canal[j] >> 8;       //soma mais 1 na varivel i para pular para a proxima posição do vetor   i++;  }  //  if(canal[0] > threshold)  {   led2_NegVal();  } } else {  Xmodem_SendError(AD1, store); } AD1_Measure(FALSE);}

 My problem is retourn value for rs232, value no modify... what i must make to request the correct value?? Sorry my english....

0 项奖励
回复

992 次查看
trytohelp
NXP Employee
NXP Employee
Hi,
 
Sorry for the delay.
This is not easy to determine the cause of the problem.
The better way will be to log it directly in the Technical support system.
Please use Freescale on line support web page.
  - Go to following URL: http://www.freescale.com/TechSupport
  - Click on Submit a Service Request. You will come to a login page.
  - You can submit your request through the web from there.
 
Please provide us more details about the Tool version used.
To do that you must:
* CW:
Start the IDE and click on Help | About Metrowerks CodeWarrior.
Click on Installed Products 
Provide us all info displayed.
Or you can save them in a txt file.
Can you please provide us your example reproducing the issue ?
 
Pascal
0 项奖励
回复