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.
Hi,
In previous discussion about the issues related to HR phase update to synchronize ePWM I was pointed to use TRREM register for HR phase update instead of TBHPSHR.
I went through the latest TRM and the example in C2000Ware (<C2000Ware_Dir>\device_support\f2837xd\examples\cpu1\hrpwm_deadband_sfo_v8) to understand the usage of TRREM.
In the TRM, the register description is as below
" 1. The lower 8-bits of the TRREM register can be automatically initialized with the TBPHSHR value on a SYNCIN or TBCTL[SWFSYNC] event or DC event (if enabled). The user can also write a value with the CPU.
2. Priority of TRREM register updates:
Sync (software or hardware) TBPHSHR copied to TRREM : Highest Priority
HRPWM Hardware (updates TRREM register): Next priority
CPU Write To TRREM Register: Lowest Priority
3. Bit 10 of TRREM register is not used in asymmetrical mode. This bit can be forced to zero."
I have few question on the explanation above
1) If we are supposed to just use 8-bits of HR phase in TRREM it is not very clear what is the use of the rest 3-bits in 11-bit register.
2) It says we can automatically initialize the TRREM register from TBPHSHR register. What is the procedure to enable this feature? If we can do this what is the need to perform software write on TRREM register through CPU?
3) What does "HRPWM Hardware(updates TRREM register)" mean? What are the settings that will cause this updates?
Also I ran the example hrpwm_deadband_sfo_v8 on hardware, I need some clarifications on the settings in the example to understand the usage of TRREM
1) For the HR phase calculation the following operations are performed. I understand that the period value is converted to 8-bit fraction value and then divided by value of 2. This value is then subtracted from 0xFF. Why do we need to do the subtraction from 0xFF?
switch(PeriodOdd)
{
case 1:
//
// Accounting for divide by 2 = 0.5
//
PhaseFine2 = 0xFF - (PeriodFine >> 9) - 0x7F;
break;
default:
PhaseFine2 = 0xFF - (PeriodFine >> 9);
break;
}
2) The final REM value is then calculated by following operation. Why do we need to add the value of 0x100 for the phase? When we are just concerned with only 8-bit value of TBHPS to update the TRREM register why the 9th bit is set here?
temp_REM2 = (Uint16) 0x100 + PhaseFine2;
3) In the ISR PRDEQfix_ISR, both ePWM1 and 2 values are updated, ePWM2 TRREM is updated with the calculated as explained above and ePWM1 TRREM value is updated with 0x100. What is the need to update the TRREM register for ePWM1 when the TBPHS value for ePWM1 is set to 0?
4) When I set breakpoint at the end of ISR with ePWM TBCTL register set to free run and try to observe the TRREM register, I see it is updated continuously and does not have the value we set in ISR. Who updates this register? Is there any way to disable the update?
Please provide the above clarifications so that I can have much better understanding on this register so that I can use it effectively for the application.
Thanks,
Aditya
Sorry for the delay, if you are not using HRPE, then the TBPSHHR can be used and it will operate correctly.
Okay here is the latest content I have:
1. with HRPE=0, the TBPSHR operates as expected.
2. For PHSDIR = 1, negative phase values: the desired value need to be subtracted from 0xFF (this will be added to the TRM)
Example: EPwm2Regs.TBPHS.bit.TBPHSHR = (Uint16)((0xFF - ((Uint16)total_phase >> 8)) << 8);
When HRPE=1 use TRREM.
Nima,
Could you clarify the following:
if high-resolution period control is enabled (HRPE=1) and I do write TBPHSHR (high-resolution part), what happens?
I am OK if I don't get the high-resolution part of the phase shift - but do I still get correct TBPHS without the high-resolution part? Or does phase shift become completely unpredictable?
Thanks!
-Pavel
If high resolution is enabled and the TBPHSHR is used, you won’t get the correct value for phase shift. As far as what it actually does and what the behavior is, I’m not sure.
The TBPHS part always works. Even when HRPE is enabled.
Hi Nima,
If I have to use TRREM register when HRPE=1, I would like to understand how to use the same. In the example, C2000Ware (<C2000Ware_Dir>\device_support\f2837xd\examples\cpu1\hrpwm_deadband_sfo_v8) I see lot of operations which involve magic number constants and I see the TRREM register descriptions is confusing in TRM which I asked above in my first question. Can you point me to the right direction on those?
Thanks,
Aditya
In the example the only part that doesn't fully describe what is happening is the 0xFF - phasevalue
Since you are using HRPE=1
For PHSDIR = 1, which corresponds negative phase values, meaning your slave PWM is actually AHEAD of the master: the phase value that you need, must be subtracted from 0xFF
Example: EPwm2Regs.TBPHS.bit.TBPHSHR = (Uint16)((0xFF - ((Uint16)total_phase >> 8)) << 8);
Hi Nima,
Thanks for the clarification on subtracting the phase from 0xFF.
Can you let me know why the following calculation was done? Addition of 0x100 to the HR phase value?
temp_REM2 = (Uint16) 0x100 + PhaseFine2;
Thanks,
Aditya
TRREM will be initialized to 0x0 and 0x100 in Up and Up-down modes respectively.
Asymmetrical Mode:
TRREM[7:0] = TBPHSHR[15:8]
TRREM[10,9,8] = 0,0,0
Symmetrical Mode:
TRREM[7:0] = TBPHSHR[15:8]
TRREM[10,9,8] = 0,0,1
I will add this to the register description.