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.

TMS320F28069: is unused HRCAP indexing in HRCAP calibration user dependent ?

Part Number: TMS320F28069
Other Parts Discussed in Thread: CONTROLSUITE

I am using HRCAP_Cal()  and int the TRM: TMS320x2806x Microcontrollers Technical Reference Manual (Rev. I) (ti.com)
Page: 414, it is mentioned that in the function: Uint16 HRCAP_Cal(Uint16 HRCAPModule, Uint16 PLLClk, volatile struct EPWM_REGS *ePWMModule)

HRCAPModule is The HRCAP module number as an integer value (that is, “1” for HRCAP1 and “2” for HRCAP2). This HRCAP module will be dedicated to calibration only and cannot be used functionally to capture pulse widths.

But when I am trying the calibrate the HRCAP in the background in my code, I always get the values of Period, On, and OFF as 69905077, 34948553, and 34948553 irrespective of the input.
I observed that using 0-based indexing for unused HRCAP Module meaning  “0” for HRCAP1 and “1” for HRCAP2 gives me the correct values, and on comparing my code with the TI example for HR 2806x, I found a difference in the definition of the HRCAP_REGS struct, in TI example it is defined as "volatile struct HRCAP_REGS *HRCAP[NUM_HRCAP] = {0, &HRCap1Regs, &HRCap2Regs,
&HRCap3Regs, &HRCap4Regs};"

and I defined it as  "volatile struct HRCAP_REGS *HRCAP[4] =  { &HRCap1Regs, &HRCap2Regs, &HRCap3Regs, &HRCap4Regs};"

when I redefined the struct for the HRCAP as  "volatile struct HRCAP_REGS *HRCAP[NUM_HRCAP] = {0, &HRCap1Regs, &HRCap2Regs,
&HRCap3Regs, &HRCap4Regs};" then I could also get the correct answers for '1' based indexing.

TRM doesn't give information about using unused HRCAP Module based on struct for HRCAPRegs,it simply says "HRCAPModule is The HRCAP module number as an integer value (that is, “1” for HRCAP1 and “2” for HRCAP2). This HRCAP module will be dedicated to calibration only and cannot be used functionally to capture pulse widths."  since HRCAP_Cal() function is not disclosed by TI, I wanted to know if unused HRCAP indexing in HRCAP calibration user dependent.

  • And why the HRCAP struct is defined as "volatile struct HRCAP_REGS *HRCAP[NUM_HRCAP] = {0, &HRCap1Regs, &HRCap2Regs,
    &HRCap3Regs, &HRCap4Regs}; "What's the significance of having the first entry as zero?  is it used for index adjustment for unused HRCAP for HRCAP_Cal()?

  • Hi,

    Looking into this. I am looking for the source code to get an answer to you on this, allow me a day to get back to you.

    Thanks,
    Aditya

  • Hi,

    I couldn't find any specific documentation on why this is the way it was written earlier. It's been continued from the time of controlSuite SDK and we don't have any expert as of now to work on this.

    I'd suggest to use the library as per the documentation provided.

    Thanks,

    Aditya

  • Hi Aditya, thanks for your response.

    Documentation doesn't give information about the HRCAP regs struct dependency on the HRCAP to be used for calibration in HRCAP_Cal(), I did change the HRCAP Struct definition (Line 141 of TI example  2806x HRCAP High res mode:  volatile struct HRCAP_REGS *HRCAP[4] = {&HRCap1Regs, &HRCap2Regs, &HRCap3Regs, &HRCap4Regs};) In the TI shipped example for 2806x HR mode as well, then I get the wrong values for 1-based indexing on sending unused HRCAP ( 1/2/3/4 ) in HRCAP_Cal(). which confirms that if we are defining struct as  "volatile struct HRCAP_REGS *HRCAP[5] =  {0, &HRCap1Regs, &HRCap2Regs, &HRCap3Regs, &HRCap4Regs};"  then only the below statement holds true in the TRM: TMS320x2806x Microcontrollers Technical Reference Manual (Rev. I) (ti.com) Page 414:

    "HRCAPModule is The HRCAP module number as an integer value (that is, “1” for HRCAP1 and “2” for HRCAP2). This HRCAP module will be dedicated to calibration only and cannot be used functionally to capture pulse widths."

    it doesn't hold true if the struct is defined as   "volatile struct HRCAP_REGS *HRCAP[4] =  { &HRCap1Regs, &HRCap2Regs, &HRCap3Regs, &HRCap4Regs};"

    here we will have to use 0/1/2 and 3 for HRCAP1/2/3/4.

     But TRM doesn't mention the effect of the HRCAP struct definition on the indexing of the HRCAP module to be used for calibration.

    As you are suggesting to use the library as per the documentation provided, I was using it like that only and was getting the wrong answer, Then only I found the dependency of HRCAP Regs struct on using the HRCAP number for calibration in the function HRCAP_Cal() which is not mentioned in the TRM.

    right now I have changed my struct definition as per the TI example, and I get the correct values if I use  “1” for HRCAP1 and “2” for HRCAP2 in the HRCAP_Cal(), But I want to confirm my reasoning, although I have verified the same in CCS.

    Regards,

    Aditya 
     

  • I think the approach to use the indexing is what we have been continuing in our other libraries as well. Your finding of defining the struct with indexing starting from 1 holds true for our other libraries as well.

    Unfortunately, I don't have the hardware handy to validate the incorrect use-case that you pointed out, but I am sure that the indexing 1 for HRCAP1, 2 for HRCAP2 would hold true as you correctly pointed out.