Part Number: TMS570LS0914
- Pin Configured : N2HET[18]
- Reading PWM duty and period through HET instruction set
void capGetSignal(hetRAMBASE_t * hetRAM, uint32 cap, hetSIGNAL_t *signal)
{
uint32 pwmDuty = (hetRAM->Instruction[(cap << 1U) + 25U].Data) >> 7U;
uint32 pwmPeriod = (hetRAM->Instruction[(cap << 1U) + 26U].Data) >> 7U;signal->duty = (pwmDuty * 100U) / pwmPeriod;
if( hetRAM == hetRAM1)
{
signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;
}
else
{
signal->period = ((float64)pwmPeriod * 1066.667F) / 1000.0F;
}
} - It is reading the correct live value
- But it is not able to read the zero/100 duty cycle
- if CP is OFF it is still holding the previous value of duty and period
- Instruction set is provided here
- /* PCNT: Capture Duty 0
* - Instruction = 25
* - Next instruction = 26
* - Conditional next instruction = na
* - Interrupt = na
* - Pin = 0
*/
{
/* Program */
0x00034E00U | (uint32)((uint32)0U << 6U) | (uint32)(0U),
/* Control */
0x00000000U,
/* Data */
0x00000000U,
/* Reserved */
0x00000000U
},
/* PCNT: Capture Period 0
* - Instruction = 26
* - Next instruction = 27
* - Conditional next instruction = na
* - Interrupt = na
* - Pin = 0 + 1
*/
{
/* Program */
0x00036E80U | (uint32)((uint32)0U << 6U) | (uint32)((0U) + 1U),
/* Control */
0x00000000U,
/* Data */
0x00000000U,
/* Reserved */
0x00000000U
},