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.

HalCoGen ADC Interrupt Problem

Other Parts Discussed in Thread: HALCOGEN

Hi,

I'm trying to read TMS570LS20216ASPGE USB Stick Kit's light sensor with ADC. I generated my code with HalCoGen with this steps:

1 - Enable ADC driver

2- Enable MIBADC1 Group1 IRQ (number 15) in VIM channel

3- in "ADC1 Group1 " panel set FIFO size to 1, SW as trigger and Enable continuous conversation mode.

In sys_main.c main function i have added this lines:

    adcInit(); // ADC module init
    adcEnableNotification(adcREG1, adcGROUP1);
    _enable_IRQ();
    adcStartConversion(adcREG1, adcGROUP1); // ADC Conversation Start
    while(1);

In adcNotification function i have added this lines:

    adcGetData(adcREG1, adcGROUP1, adc_data_ptr); // Store conversion into ADC pointer
    value = (unsigned int)adc_data_ptr->value;

Of course i define as a global variable adc_data_ptr and value.

Here is my problem. I'm watching ADC1 group1 buffer from register windows of CCS and it seemed ADC interrupt called only once so i could not read continuosly. value variable changed once at the start of my program.

I guess my mistake is about triggering ADC interrupt. I could read ADC continuosly even at single mode conversation mode with starting adc conversation again and again in a while statement.

  • still i can not solve my problem. it seems interrupt flag of adcgroup1 can not clear at interrupt function. i try to clear it manually with writting adc1group1 register but nevertheless it did not works.

  • Hello,

    The group end status interrupt cannot be reliably used when the group is configured to be in continuous conversion mode. In this case, you can use the threshold interrupt condition to trigger an interrupt.

    Please confirm whether you are using the group1 conversion end status (bit 3 of ADG1INTFLG register) or the group1 threshold interrupt condition (bit 0 of ADG1INTFLG register) for the interrupt.

    Regards, Sunil

  • Hi Sunil,

    I'm new on TI products so i generate my code with halcogen and use its own functions instead of writting registers directly. I checked again the interrupt function after your post  which HalCoGen generates, and at this function G1INTFLG sets to 9  (in other words it sets bit0 and bit3)

    adcREG1->GxINTFLG[1U] = 9U;

    Despite the interrupt function sets G1INTFLG=9, when i debug and watch the registers i saw G1INTFLG sets to 0x0A (bit 3 and bit 2). And then i have checked Tech. Ref. Manual of my microcontroller and G1INTFLG's bit0 and bit3 defines Group1 Conversion End and Group1 Memory Overrun. Here is the ss of my register window:

    So i don't get why memory overrun flag sets and how i can use threshold interrupt condition instead of conversation end status.


    Thanks.

  • I solved my problem with setting fifo size to 16. I was setting it to "one" before and when i saw my interrupt register's overrun bit set to 1 , i thought it might because of fifo size.

    Although i have solved my problem, still i can't understand why Interruptflag register's overrun buffer sets, when i select fifo size one.

  • Furkan,

    A size of "one" means that there are two buffers for storing that group's conversion results. This generates a memory overrun condition when the ADC is about to store the 3rd conversion result in that group.

    Regards, Sunil