This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC_TRIGGER_PROCESSOR

Other Parts Discussed in Thread: TM4C123GH6PGE

hi,

i use TM4C123GH6PGE and keil development, CAN in interrupt Handler, SPI and ADC (PE4 (IN09)) in ADC_TRIGGER_PROCESSOR. The problem is : when i send a SDO CAN to the board, ADC value register is not refresh all the time and i have a bad value! I think the trigger generated by the processor is stopped by CAN task!

in debug mode, Under task CAN SDO, i watch ADC register refreshed periodically but when i send CAN SDO, ADC register stop to refresh and refresh step when i send CAN SDO. SPI works good

the configuration:

SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);

 init ADC:

//Enable ADC peripheral
  SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);   
  //Configure pin for ADC reading
  GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_4);
  //Disable sample sequencer before configure it
  ADCSequenceDisable(ADC0_BASE, 0);
  //Configure sample sequencer
  ADCSequenceConfigure(ADC0_BASE, 0, ADC_TRIGGER_PROCESSOR , 0);
  //Configure sample step for the sample sequencer
  ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH9 |  ADC_CTL_END);

  //Configure number of sample used to calculate average
  ADCHardwareOversampleConfigure(ADC0_BASE,64);
   //Once sample sequencer has been configured, enable it
  ADCSequenceEnable(ADC0_BASE, 0);

i have a task to call ADCProcessorTrigger(ADC0_BASE, 0); before to call task UpdateADC value:

uint32_t tmpArray_ADCValue[1];

isADCBusy = ADCBusy(ADC0_BASE);

if( isADCBusy == TRUE )
{}
else
 { //ADC is not busy

  //ADC has finished sampling, we can get the data.
  nbrSamplesCopiedToBuffer = ADCSequenceDataGetADC0_BASE, 0,tmpArray_ADCValue);
   
  if(nbrSamplesCopiedToBuffer > 0)
  {
    //Update model with new HOB angle value.
    HOB_Model.fields.HOB_Raw_Value = tmpArray_ADCValue[0];     
  }

 }

ADC configuration is it correct? is it a problem of priority between CAN and ADC (DMA, etc..)

first i would not use ADC in interrupt Handler mode., is it possible to force processor event to refresh ADC register?

Thanks for your help

  • I rather suspect you are spending too much time in the CAN interrupt, and provoke an ADC overflow. There is no such kind of peripheral interconnection between CAN and ADC, except through your code. Other (less likely possibilities) are stack overflow, or another incorrect access.

    I would try to visualize the interrupt load.

    And, if possible, post the CAN interrupt code. SDO sounds like CanOpen - not a "very lightweight" stack. Avoid processing long messages in interrupt context.

  • Hello,

    f.m is giving good advice and taken a bit further it seems the configuration could be suspect. The (processor_trigger) as Amit past advised me only starts the sample sequence.

    >ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH9 | ADC_CTL_END);

    This way seems to work great, though datasheet states you can END on any step it leaves out that you can't do that in the sample step yet you can interrupt on any sample step.

    ADCSequenceStepConfigure(ADC0_BASE, 0, 0, ADC_CTL_CH9 | ADC_CTL_IE);
    ADCSequenceStepConfigure(ADC0_BASE, 0, 1, ADC_CTL_END);