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.

Compiler/TMS570LS0432: ADC SAMPLE using interrupt

Part Number: TMS570LS0432
Other Parts Discussed in Thread: HALCOGEN

Tool/software: TI C/C++ Compiler

Hello 

 When I use the timer interrupt to set the ADC sampling .timer 50us once.

code:

  uint16_t Amplitude_value[COLLECT_POINTS];

interrupt function

{

adcStartConversion(adcREG1,adcGROUP1);

while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);
adcGetData(adcREG1, adcGROUP1,&adc_data[0]);

Amplitude_value[AD_COUNT]=adc_data[0].value;

}

I found that this interrupt function sometimes responds more than 50us.so affect the effect.

please. Can I set it only sample the interrupt function ,and perform the ADC conversion function in the main program so that it will not affect the interrupt function.

Or there are other ways to reduce the code as in the interrupt function, but it must be sampled once every 50us.

 

  • Hello Whong,

    The ADC can be configured to be hardware triggered using supports RTI compare 0 interrupt. 

    1. Configure the ADC trigger from HALCOGen

    2. Change your code. Enable RTI compare 0 in main(); and run adcStartConversion(adcREG1,adcGROUP1); In RTI compare 0 interrupt function, wait conversion to be completed, then read the data from ADC RAM.

    main()

    {

        rtiInit();

        adcStartConversion(adcREG1,adcGROUP1);
    }

    RTI COmpare 0 ISR()               ---> this interrupt triggers the ADC sampling, you don't need to run adcStartConversion() in ISR.

    {

    while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);
    adcGetData(adcREG1, adcGROUP1,&adc_data[0]);

    Amplitude_value[AD_COUNT]=adc_data[0].value;

    }

  • OK!

    Thank you