AnsweredAssumed Answered

MQX 4.0   3 adc channel opens crash the task

Question asked by albert calpito on Jul 3, 2013
Latest reply on Jul 10, 2013 by Monica Arvizu

MQX 4.0     K20N512VLQ100

 

 

 

 

When I try to open 3 ADC channels, the calling task does not make it past the 3rd fopen call.

Opening 2 ADC channels works, but the 3rd seems to crash the task.

 

I have already made the appropriate defines for more than 2 adc channels:

    #define ADC_MAX_SW_CHANNELS       (3)

     #define ADC_CHANNELS_PER_ADC (3)

 

 

When I call the 3rd fopen(   fopen("adc0:4"  )    in my IAR debugger, I am able to get to the following line in the adt_kpdb.c file:

     PDB0_BASE_PTR->SC |= PDB_SC_LDOK_MASK; /* write new DLY value */

After this line is executed, the program seems to never return to the main_task.

 

 

Does anyone see any issues with the following code sequence?:

void my_main_task(uint_32 initial_data) 
{
  LWEVENT_STRUCT adc_event;
  MQX_FILE_PTR adc0_ID;
  MQX_FILE_PTR channel_id;
  ADC_INIT_CHANNEL_STRUCT adc0_params;
  ADC_INIT_STRUCT adc_init = { ADC_RESOLUTION_DEFAULT,     /* resolution */};

  _lwevent_create(&adc_event,0);


  adc0_ID = fopen("adc0:", (const char*)&adc_init);

 

  adc0_params.source = ADC0_SOURCE_AD8;  /* one of ADC_SOURCE_* definitions defined in ./<module_name>/adc_<module_name>.h - CPU specific header file */
  adc0_params.flags = (ADC_CHANNEL_MEASURE_LOOP | ADC_CHANNEL_START_TRIGGERED);  /* initialization flags, combination of ADC_CHANNEL_<FLAG_NAME> possibilities above */
  adc0_params.number_samples = 10;  /* number of samples in one run sequence, the number of samples needed to trigger event */
  adc0_params.time_offset = 50;    /* the time offset applied once after measurement on given channel is started, in microseconds */
  adc0_params.time_period = 100000;  /* the time slot between two samples in microseconds */
  adc0_params.range = 0x10000;  /* scale range of result (not used now) */
  adc0_params.buffer_size = 10;  /* ADC output buffer size, measured samples are stored here */
  adc0_params.trigger = 0x10000;  /* trigger mask that fires this channel */
  adc0_params.complete_event = &adc_event;  /* pointer to lwevent to be signaled after nuber_samples is measured */
  adc0_params.event_mask = 0x01;  /* event mask to be signalled in lwevent after nuber_samples is measured */


  channel_id = fopen("adc0:1" , (const char*)&adc0_params);  /*this will request to open this channel*/

  adc0_params.source = ADC0_SOURCE_AD9;  /* one of ADC_SOURCE_* definitions defined in ./<module_name>/adc_<module_name>.h - CPU specific header file */
  channel_id = fopen("adc0:2" , (const char*)&adc0_params);  /*this will request to open this channel*/

  adc0_params.source = ADC0_SOURCE_DM1;  /* one of ADC_SOURCE_* definitions defined in ./<module_name>/adc_<module_name>.h - CPU specific header file */
  channel_id = fopen("adc0:4" , (const char*)&adc0_params);  /*this will request to open this channel*/


  while(1)
  {
    _time_delay(1000);
  }


  _task_block();
}

 

Outcomes