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.

Simultaneous conversion proglem [TMS570LS1227 ADC]

Other Parts Discussed in Thread: TMS570LS1227, HALCOGEN

Hi,

I have three question of TMS570LS1227 ADC.

I use CCSv5.5 & HalCoGen v03.09.00.

(1) I want to simultaneous sampling ADC1 and ADC2 to trigger the EPWM_A2.

HalCoGen  is the setting as shown in the figure.

I think no problem to HalCoGen setting, but they are not set correctly it becomes PINMMR32[8]=1 & PINMMR32[9]=0.

It should be the value of the below would otherwise.

Do not support setting of PINMMR32 in HalCoGen?

 

(2) ADC2 is set to Rising Edge Triger. (See figure of my HalCoGen)0871.LS1227_ePWM_MibADC2.zip

but they are not set correctly it becomes ADEVSRC[EV_EDG_SEL] = 0.

It should be the value of the below would otherwise.

Do not support setting of ADC2 ADEVSRC[EV_EDG_SEL] in HalCoGen?

By the way, ADC1 has been set correctly (1) & (2).

 

(3) I can not solve the problem of the above, I wrote the program as attached(LS1227_ePWM_MibADC2.zip).

Now ADC1&ADC2 is running on simultaneous sampling.

But there is one problem.

ADC1&ADC2 is converted correctly in the first conversion.

However, the value of ADC1 is not correct from the second time.
(ADC2 is converted correctly second and subsequent)

Do you know the reason for this problem anyone?

Regards,

FSSer

  • Hi,

    FSSer said:
    I use CCSv5.5 & HalCoGen v03.09.00.

    (1) I want to simultaneous sampling ADC1 and ADC2 to trigger the EPWM_A2.

    HalCoGen  is the setting as shown in the figure.

    I think no problem to HalCoGen setting, but they are not set correctly it becomes PINMMR32[8]=1 & PINMMR32[9]=0.

    It should be the value of the below would otherwise.

    Do not support setting of PINMMR32 in HalCoGen?

    Did you try the 'Special Pin Muxing' tab under Pinmux.  There are two buttons there - "Use Alternate ADC Trigger Option A' and one for option B.   You should select option B for ePWM_A2.

    FSSer said:
    (2) ADC2 is set to Rising Edge Triger. (See figure of my HalCoGen)0871.LS1227_ePWM_MibADC2.zip

    but they are not set correctly it becomes ADEVSRC[EV_EDG_SEL] = 0.

    It should be the value of the below would otherwise.

    Do not support setting of ADC2 ADEVSRC[EV_EDG_SEL] in HalCoGen?

    By the way, ADC1 has been set correctly (1) & (2).

     

    FSSer said:
    (3) I can not solve the problem of the above, I wrote the program as attached(LS1227_ePWM_MibADC2.zip).

    Now ADC1&ADC2 is running on simultaneous sampling.

    But there is one problem.

    ADC1&ADC2 is converted correctly in the first conversion.

    However, the value of ADC1 is not correct from the second time.
    (ADC2 is converted correctly second and subsequent)

    Do you know the reason for this problem anyone?

    How is ADC1's result incorrect?  Is it not converting or do you think the value is wrong.

    If wrong - how much of an error are you seeing?

  • Thank you for reply.

    Anthony F. Seely said:

    Did you try the 'Special Pin Muxing' tab under Pinmux.  There are two buttons there - "Use Alternate ADC Trigger Option A' and one for option B.   You should select option B for ePWM_A2.

    I have set as follows.

    Anthony F. Seely said:
    How is ADC1's result incorrect?  Is it not converting or do you think the value is wrong.

    If wrong - how much of an error are you seeing?

    ADC1 First conversion : About  2500(dec)
    ADC2 First conversion : About  2500(dec)
     
    ADC1 Second conversion : About  1000(dec)
    ADC2 Second conversion : About  2500(dec)
     
    ADC1 N-th conversion : About  1000(dec)    (N = 2, 3, 4, ....)
    ADC2 N-th conversion : About  2500(dec)
     
    It is converting.
    Because I have read the data using the ADC1 interrupt service routine.
     
    Thanks and regards,
     
    FSSer
     
     
  • FSSer,

    ADIN1[1] and ADIN2[1] are on different pins, so unless you have them wired together the result will be different.

    We have ADIN2[1] sharing a pin with ADIN1[17] in case you want to use the on-chip connection.

    I also see that you have option to discharge the sample cap set for one ADC and not the other.

    That could make a difference in your result especially if you are not leaving enough sample time for your input single to settle. 

    So please try setting both ADCs to discharge, making sure the inputs are the same and if they still mismatch a little try increasing the sample time.  The datasheet does have an equivalent circuit for the ADC input in case you want to do a calculation of what your sample time should be set to.... this also depends on your input's source impedance and any capacitor values you have externally on the ADC input.

  • Anthony,

    Thank you .

    Anthony F. Seely said:
     

    ADIN1[1] and ADIN2[1] are on different pins, so unless you have them wired together the result will be different.

    We have ADIN2[1] sharing a pin with ADIN1[17] in case you want to use the on-chip connection.

    Sorry...

    Since I wasn't on top of making sure of things, I overlooked that.

    Now, It is working correctly by changing to AD1IN[08] & AD2IN[08] pin.

    Thank you for your kindness.

    By the way, how might it be (1) and (2).
    HalCoGen Do not support the ADC2?

    Regards,

    FSSer

  • Hi FSSer,  

    Glad things are working now. 

    FSSer said:
    By the way, how might it be (1) and (2).
    HalCoGen Do not support the ADC2?

    I didn't understand what (1) and (2) below refer to though;  HalCoGen does support both ADCs.

     

  • Hi.

    My HalCoGen Setting is as follows.

    Then the register value should be: PINMMR32[8] =0 & PINMMR32[9] = 1

    But, Generated code of HalCoGen is as follows.

    Therefore, ADC2 triger setting is not EPWM_A2 triger.

    So I thought  I would not be able to set up ADC2 Triger setting in HalCoGen.

    Best Regards,

    FSSer

  • Any news?

    Please inform us about the current status.

    Regards,

    FSSer

  • FSSer,

    It's working in HalCoGen 4.00.00;  I didn't go back to the older versions to double check.
    You might want to just make sure that you hit 'generate code' again after changing settings.

    Otherwise, probably the thing to do is move to 4.00.00  or alternatively manually write to PINMMR32 again after the automatically generated code finishes.

    If you take the latter approach which might be the least disruptive to you in the short term, you'd want to do this in pinmux.c.

    You should see in the function muxInit() that one of the first steps is:

        /* Enable Pin Muxing */
        kickerReg->KICKER0 = 0x83E70B13U;
        kickerReg->KICKER1 = 0x95A4F1E0U;

    The comment might have been better as 'unlock writes to the pinmuxing registers'.

    Near the end of the file you will see something like:

    /* USER CODE BEGIN (6) */
    /* USER CODE END */
       
        /* Disable Pin Muxing */
        kickerReg->KICKER0 = 0x00000000U;
        kickerReg->KICKER1 = 0x00000000U;

    Where the write of 0's locks the pinmux MMRs again.

    If you want to override how HalCoGen is setting the pinmux mmrs as a workaround the best place to do this would be to insert your own write to pinmux register 32 right in the user code (6) area.   Because you need to do it while the pinmux registers are unlocked, or the writes will be ignored by hardware [a protection mechanism against inadvertently changing the pinmux due to something like runaway code...]

    -Anthony

  • Anthony,

    Thank you for reply.

    I generated correctly after updating HalCoGen.(HalCoGen 3.90.00 -> HalCoGen 4.00.00)

    I use "HalCoGen 4.00.00" from now on.

    Anthony said:

    If you want to override how HalCoGen is setting the pinmux mmrs as a workaround the best place to do this would be to insert your own write to pinmux register 32 right in the user code (6) area.   Because you need to do it while the pinmux registers are unlocked, or the writes will be ignored by hardware [a protection mechanism against inadvertently changing the pinmux due to something like runaway code...] 

    Until now, I had set pinmux registers as described above.

    It was a great help!

    Regards,

    FSSer