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.

Problems in TMS570LC4357 ADC conversion

Other Parts Discussed in Thread: TMS570LC4357, HALCOGEN

I am using the TMS570LC4357 in my project. In such ECU, there are two ADC units, ADC1 and ADC2. Within either ADC, there is "event group", "group1" and "group2". Each group includes several channels. I selected some channels in "event group" and "group 1" in both ADC1 and ADC2.

However, I am having one issue: When I loaded the code into the board and ran it, ADC conversion worked fine. But, when I power-cycled the board. ADC channels in "event group" still worked fine but ADC channels in "group 1" were not working.  I found it by  transferring the ADC results out through CAN bus. When the board was power-cycled, the ADC results from the channels in "group 1" were always "0" while the ADC results from the channels in "event group" were always correct. (I can make sure that CAN bus communication is correct.)


I have no clues even after checking the ADC settings. (ADC conversion files were generated by HALcogen). I am kinda stuck. Can anyone give me some tips?

Thanks  a lot!

  • How is group1 triggered? You may want to toggle an I/O pin at the code which generates the trigger to see if there is anything missing in the software.

    Thanks and regards,

    Zhaohong
  • Hi Zhaohong,


    Thanks for your reply!

    The group 1 was hardware-triggered. The adc file was generated by Halcogen. The thing is both Event Group and Group 1 settings are the same (adcREG1->EVSRC and adcREG1->G1SRC), then how come ADC in Event group is working while the Group 1 is not?

    Here are my settings:

     /** - Setup event group conversion mode
        *     - Setup data format
        *     - Enable/Disable channel id in conversion result
        *     - Enable/Disable continuous conversion
        */
        adcREG1->GxMODECR[0U] = (uint32)ADC_12_BIT
                              | (uint32)0x00000000U
                              | (uint32)0x00000000U;

        /** - Setup event group hardware trigger
         *     - Setup hardware trigger edge
         *     - Setup hardware trigger source
         */
        adcREG1->EVSRC = (uint32)0x00000008U
                       | (uint32)ADC1_EPWM_B;

        /** - Setup event group sample window */
        adcREG1->EVSAMP = 0U;

        /** - Setup event group sample discharge
        *     - Setup discharge prescaler
        *     - Enable/Disable discharge
        */
        adcREG1->EVSAMPDISEN = (uint32)((uint32)0U << 8U)
                             | (uint32)0x00000000U;

        /** - Setup group 1 conversion mode
        *     - Setup data format
        *     - Enable/Disable channel id in conversion result
        *     - Enable/Disable continuous conversion
        */
        adcREG1->GxMODECR[1U] = (uint32)ADC_12_BIT
                              | (uint32)0x00000000U
                              | (uint32)0x00000008U
                              | (uint32)0x00000000U;

        /** - Setup group 1 hardware trigger
         *     - Setup hardware trigger edge
         *     - Setup hardware trigger source
         */
        adcREG1->G1SRC = (uint32)0x00000008U
                       | (uint32)ADC1_EPWM_B; /* Alternate Trigger Source */

        /** - Setup group 1 sample window */
        adcREG1->G1SAMP = 0U;

        /** - Setup group 1 sample discharge
        *     - Setup discharge prescaler
        *     - Enable/Disable discharge
        */
        adcREG1->G1SAMPDISEN = (uint32)((uint32)0U << 8U)
                             | (uint32)0x00000000U;


    Thanks a lot!!


    Yue

    Zhaohong Zhang said:
    How is group1 triggered? You may want to toggle an I/O pin at the code which generates the trigger to see if there is anything missing in the software.

    Thanks and regards,

    Zhaohong

  • You have both the groups triggered by the same edge of the same source event. There is an inherent priority between the conversion groups, with the event group being the highest priority followed by group1 and then group2. This is why you always see the event group serviced first.

    The group1 conversions will follow event group conversions unless a new trigger comes in before the event + group1 conversion sets are completed. Can you confirm that the next trigger edge occurs only after there is sufficient time for the two sets of conversions to complete?
  • Hi Sunil,

    Thanks for your answer.
    Yes, there is sufficient time between the two sets of conversions, otherwise group1 of ADC would not work when I loaded the code and ran it. Now, the issue that I am facing is : When I loaded the code into the board and ran it immediately, it worked great! However, after I power-cycled the board, only event group of ADC was still working but the group 1 ADC was not.....that means,group 1 of ADC worked fine unless I power-cycled the board. BTW, event group was never affected by the power-cycling the board.

    Maybe it was trigger issue (?) I am checking it now but event group and group 1 have the same trigger settings, how come the ADC conversion in group 1 is not working when the board is power-cycled??

    Thanks, again!

    yue
  • There is something missing in your software. I would suggest you disabling the event group and only enable group 1 and observe the behavior.

    Thanks and regards,

    Zhaohong
  • Hi Zhaohong,


    I disabled "event group" by "deselecting" the channels in event group. Now, only group1's channels are selected.

    I can see clearly that ADC results from event group don't work, which is true since no channels there were selected. But, for group 1, it is the same as before, when I loaded the code and ran it immediately, it was working fine; after I power-cycled the board, group 1 didn't work....

    Thanks!

    Yue

  • Hi Sunil,

    I read your post again and the ref manual. I think I might be closer to the reason. Firstly, in my code, the Event group was hardware triggered by ADC1_EPWM_B. The Group 1 was software- triggered and alternate trigger is hardware trigger which was also ADC1_EPWM_B.
    When I loaded the code and ran it, the software-trigger for my group1 was working fine. But, when I power-cycled the board, for some reason, the software-trigger for Group1 was not working. Then, the alternate hardware trigger kicked in, that is ADC1_EPWM_B. Now, the event group and group 1 share the same hardware trigger. Since the event group has higher priority as you said, whenever the ADC1_EPWM_B came, the even group'd work but the group 1 could not be executed.

    If my thinking is correct, I could either fixed the software trigger in my code or has new hardware-trigger for group 1 (?)
  • Please use following steps in debugging.

    (1) load your code to flash.
    (2) do a power on reset.
    (3) load the symbols for the code.
    (4) connect CCS to target.
    (5) do a system reset from CCS.
    (6) Use CCS to control the execution. Check ADC registers to see what is missing.

    Thanks and regards,

    Zhaohong