AnsweredAssumed Answered

Adc read

Question asked by Daniele Cortellazzi on Aug 26, 2013
Latest reply on Aug 29, 2013 by Daniele Cortellazzi

Hi, i'm trying to read a data from the ADC on a TWRMCF51MM256 but i have a problem with the function

 

adc_ch4 = fopen("adc:four", (const char*)&adc_channel_param4);//inizializzo il canale quattro dell'adc

 

that return a null, and where the parameter are

 

ADC_INIT_CHANNEL_STRUCT adc_channel_param4 = {
  ADC_SOURCE_AD4, /* physical ADC channel */
  ADC_CHANNEL_MEASURE_ONCE | ADC_CHANNEL_START_NOW, /* one sequence is sampled after fopen */
  1,             /* number of samples in one run sequence */
  0,         /* time offset from trigger point in us */
  600000,         /* period in us (= 0.6 sec) */
  0x10000,        /* scale range of result (not used now) */
  1,             /* circular buffer size (sample count) */
  MY_TRIGGER,     /* logical trigger ID that starts this ADC channel */
  };

 

what i want to do is to read the data every second with this function

 

for(;;){
  printf("Triggering channel #4...");
  ioctl(adc_file, ADC_IOCTL_RUN_CHANNEL, NULL);
  if(read(adc_ch4, &data, sizeof(data)))
  printf("ADC ch 4: %4d ", data.result);
  _time_delay(1000);
  }

 

when is called the function ioctl the sistem stop to work, where is the error?

Sorry but I am at the beginning with this operating system

Thanks

Outcomes