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.

Whether there is a simple about data simpling by adc?

Other Parts Discussed in Thread: RM48L952, HALCOGEN, TMS570LS3137

Hi,

    I want realize the single channel data simpling by adc, and there is just a simple about adcdisplay in HAL.

    

  • Hi user4460717,

    There's no special function to sample one channel instead of a group.
    To sample one channel, you have to just use one of the groups like ADC Group 2, and write the channel number to the GxSEL register. The closest function is adcStartConversion() but it uses the group configuration set by adcInit() or the GUI.

    If you want to change the group configuration - for example sometimes convert channel 5 and other times convert channel 7, you could try changing the bitmask s_adcSelect[index][group] and then calling adcStartConversion. If that doesn't work it may be simpler to make your own variant of adcStartConverstion that takes the GxSEL bitmask as a parameter.
  • Hi,
    Firstly,Thanks for your reply.
    I find the example named adcDisplay in HAL-software example package.After analysing this example,and I have some
    questions about it. I hope that you can give me some answers with your experience.
    The follows is one part of the main code:
    while(1) /* ... continue forever */
    {
    /* trigger using gio port b, pin 0 */
    gioSetBit(gioPORTB, 0, 1);

    /* ... wait and read the conversion count */
    while((adcIsConversionComplete(adcREG1,adcGROUP1))==0);
    ch_count = adcGetData(adcREG1, adcGROUP1,&adc_data[0]);

    /* conversion results : */
    /* adc_data[0] -> should have conversions for Group1 channel1 */
    /* adc_data[1] -> should have conversions for Group1 channel2 */
    id = adc_data[0].id;
    value = adc_data[0].value;

    gioSetBit(gioPORTB, 0, 0);

    //通过sci进行输出
    UartPrintf("CH.ID=%2x\tValue=%12d\r\n",id,value);

    id = adc_data[1].id;
    value = adc_data[1].value;

    UartPrintf("CH.ID=%2x\tValue=%12d\r\n",id,value);
    wait(0xFFFFFF);
    };

    Questions:
    Q1,I know that the adc1 is triggering by GIOB0 with set the output of GIO pin high.And what I confused is that the
    connection between GIO and ADC? or what is the process between set GIO to high with ADC works? There is a signal which GIO
    send to ADC or the ADC checks the status of the GIO0?

    Q2,Is it a hardware Triggling about setting GIO high? And Can you show me the other methods to trigger the adc works
    such as SW_Interrupt、Clock and DMA and so on.

    3,The follow is the function of adcGetData():
    if(mode == ADC_12_BIT_MODE)
    {
    /** - Get conversion data and channel/pin id */
    for (i = 0U; i < count; i++)
    {
    buf = adc->GxBUF[group].BUF0;
    /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Valid non NULL input parameters are only allowed in this driver" */
    ptr->value = (uint16)(buf & 0xFFFU);
    ptr->id = (uint32)((buf >> 16U) & 0x1FU);
    /*SAFETYMCUSW 567 S MR:17.1,17.4 <APPROVED> "Pointer increment needed" */
    ptr++;
    }
    }

    Q3,The code use for-loop to get the data and store into a array.the main code is buf = adc->GxBUF[group].BUF0; I run
    step by step to check the data, and everytime the data is different, I don't know the reason. And during the circulation,the
    value of the INTCR is changed from 14 to 16 circularly.I hope that you can give me some answers.

    Q4,At the same time, Every cycle of the main code, the INTFLG set to 8.If there is not the gioSetBit(gioPORTB, 0, 0),
    the value of the INTFLG is 4, and in next cycle it will in the while((adcIsConversionComplete(adcREG1,adcGROUP1))==0)
    always.What I want to know is that the trigger is the status or the process of polling up and polling down?

    If you can give me the answer and I will be appreciate it very much, and I will wait for your reply with regards.
    thanks!

  • Hi user4460717,

    The DMA conversion groups can be initiated by software or by an even trigger. It sounds like you are working with an event triggered example.
    I'm not sure which device you are using but in each datasheet you will find a section under the ADC that lists the possible sources for event triggering. These are device-level cross triggers between modules.
    For RM48L952 as an example: www.ti.com/.../spns177d.pdf you can look at 7.2.2 Event Trigger Options..

    You will find that both the MibADC and MibSPI support this type of cross-triggering - which can be useful as a pin or timer event can cause an action automatically without CPU involvement. This makes timing very regular and fast as CPU interrupt latency is removed from the equation.

    For the ADC in particular there are several tables that select the trigger sources - you have a few options. Once you pick a table (table selection is done through the pinmux tab in HalCoGen)
    then you've picked 8 different possible trigger sources.

    After this, you can pick the trigger for each of the ADC groups from among the 8 sources, in HalCoGen you will see tabs like 'ADC1 Group Event' and there will be a trigger box. The signals are listed in the drop down and you can pick one for each group. Then you can also pick the polarity you want to trigger on - rising or falling edge of the signal. Groups1 and 2 can be *either* event triggered or *software* triggered.

    If you set the group to be software triggered, then the trigger occurs when you write to the channel select register.

    Hopefully above answers Q1 and Q2..


    For Q3, you are reading from a FIFO when you read the buf register, so this would mean that each read potentially pulls a new value out of the FIFO. There is also one bit (MSB) that indicates a read from the FIFO when the FIFO is empty. So if you get a negative result for the conversion - this means it's invalid (you read the FIFO when the FIFO is empty). You can also decide to make the channel # visible in the MSBs of the result so each read of the FIFO will be tagged with the channel # - this can be useful for debugging in particular or just confirming that the conversion result comes from the channel that you expect. I think you see this in the example you posted - where it extracts the channel ID (channel #) and conversion result from different fields of the 32-bit value read from the FIFO.


    I'm not really sure about question 4 - but will give it a shot. The test while((adcIsConversionComplete(adcREG1,adcGROUP1))==0); is testing to see if the conversion of the entire group (all channels in the channel select register) finished and there is data in the FIFO for all the channels for you to read.

    If you use an event trigger for the group, then if you never trigger the group you wouldn't expect to see that the conversion for that group completes.

    At the same time, the conversion complete flag will lag the trigger by some number of microseconds usually ... how ever long it takes to convert all the channels you have in the channel select register. (and each channel takes at least about 600-700ns ..)
  • Hi,Anthony
    Thanks for your reply.After learning from your answers, it is more light
    about the process of hardware event-triggered.

    I am using the board of TMS570LS3137, And I know that there are some other
    methods to realize the Single Channel Data Simpling.
    In the former answers, you make mention of the software triggered.And now, I want to use the other meathods to realize it.
    In the future, I want to realize the SoftWare Check and DMA Check triggered.
    Could you tell me that the process of them and Is there an example about it? I have found in the DataSheet Document, and find nothing about the realization methods. If it is convenient for you, Please give me a process in detail or some useful documents. thanks.