Part Number: RM48L952
Other Parts Discussed in Thread: HALCOGEN, DRV8301,
Tool/software: Code Composer Studio
Hey there,
I am driving a three phase BLDC motor using XRM48L952ZWT control card
I have done my complete coding in Code Composer Studio
I have only enabled the GIO and HET drivers from HALCoGen while all of the controlling is being done through the code being burned.
here is my code
/*Include Files*/
#include "sys_common.h"
#include "system.h"
#include "gio.h"
#include "het.h"
void het_setting()
{
hetREG1->DOUT = (0U << 31U)
| (0U << 30U)
| (0U << 29U)
| (0U << 28U)
| (0U << 27U)
| (0U << 26U)
| (0U << 25U)
| (0U << 24U)
| (0U << 23U)
| (0U << 22U)
| (0U << 21U)
| (0U << 20U)
| (0U << 19U)
| (0U << 18U)
| (0U << 17U)
| (0U << 16U)
| (0U << 15U)
| (0U << 14U)
| (0U << 13U)
| (0U << 12U)
| (0U << 11U)
| (0U << 10U)
| (0U << 9U)
| (0U << 8U)
| (0U << 7U)
| (0U << 6U)
| (0U << 5U)
| (0U << 4U)
| (0U << 3U)
| (0U << 2U)
| (0U << 1U)
| (0U);
/** - Set HET pins direction */
hetREG1->DIR = 0xFFFFFFFFU
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Set HET pins open drain enable */
hetREG1->PDR = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Set HET pins pullup/down enable */
hetREG1->PULDIS = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Set HET pins pullup/down select */
hetREG1->PSL = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Set HET pins high resolution share */
hetREG1->HRSH = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Set HET pins AND share */
hetREG1->AND = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/** - Set HET pins XOR share */
hetREG1->XOR = 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U
| 0x00000000U;
/* USER CODE BEGIN (1) */
/* USER CODE END */
hetREG1->PFR = (6U << 8U)
| (0U);
}
/* USER CODE BEGIN (2) */
hetSIGNAL_t Set_Duty_Period1,Set_Duty_Period2,Set_Duty_Period3,Set_Duty_Period4,Set_Duty_Period5,Set_Duty_Period6;
void main(void)
{
/* USER CODE BEGIN (3) */
unsigned int i=0,j,k,l,m,n,o;
gioInit();
gioSetDirection(gioPORTA,0x10); //masking for EN_GATE
gioSetBit(gioPORTA,4,1); // seeting bit for EN_GATE
//gioSetDirection(gioPORTB,0x08); //masking for nFAULT
//gioSetBit(gioPORTB,3,1); // seeting bit for nFAULT
gioSetDirection(hetPORT1, 0xFFFFFFFF); //setting direction for all HET1 pins
while(1)
{
//Ist Cycle
for(j=0;j<5;j++)
{
/*start of for first loop*/
gioSetBit(hetPORT1, 0, 1); // output on PWM_AH
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 6, 1); // output on PWM_BL
//gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for high time of 16.8usec (do set a scale of 200usec on scope) */
}
gioSetBit(hetPORT1, 0, 1); // output on PWM_AH
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
//gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for low time of 16.8usec (do set a scale of 200usec on scope) */
}
} /*end of for loop*/
// gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
// gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
// gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
//2ND Cycle
for(j=0;j<5;j++)
{
/*start of for first loop*/
gioSetBit(hetPORT1, 0, 1); // output on PWM_AH
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for high time of 16.8usec (do set a scale of 200usec on scope) */
}
gioSetBit(hetPORT1, 0, 1); // output on PWM_AH
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
gioSetBit(hetPORT1, 10, 1); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for low time of 16.8usec (do set a scale of 200usec on scope) */
}
} /*end of for loop*/
// gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
// gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
//3RD Cycle
for(k=0;k<5;k++)
{
/*start of for first loop*/
gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
gioSetBit(hetPORT1, 4, 1); // output on PWM_BH
//gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
gioSetBit(hetPORT1, 10, 1); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for high time of 16.8usec (do set a scale of 200usec on scope) */
}
gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
gioSetBit(hetPORT1, 4, 1); // output on PWM_BH
//gioSetBit(hetPORT1, 2, 1); // output on PWM_AL
gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for low time of 16.8usec (do set a scale of 200usec on scope) */
}
} /*end of for loop*/
// gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
// gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
// gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
//4TH Cycle
for(k=0;k<5;k++)
{
/*start of for first loop*/
gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
gioSetBit(hetPORT1, 4, 1); // output on PWM_BH
gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
//gioSetBit(hetPORT1, 10, 1); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for high time of 16.8usec (do set a scale of 200usec on scope) */
}
gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
gioSetBit(hetPORT1, 4, 1); // output on PWM_BH
gioSetBit(hetPORT1, 2, 1); // output on PWM_AL
//gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
i=0;
while(i<1000)
{
i++; /* for low time of 16.8usec (do set a scale of 200usec on scope) */
}
} /*end of for loop*/
// gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
// gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
// gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
//5TH Cycle
for(l=0;l<5;l++)
{
/*start of for first loop*/
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 8, 1); // output on PWM_CH
gioSetBit(hetPORT1, 2, 1); // output on PWM_AL
//gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
i=0;
while(i<1000)
{
i++; /* for high time of 16.8usec (do set a scale of 200usec on scope) */
}
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 8, 1); // output on PWM_CH
gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
//gioSetBit(hetPORT1, 6, 1); // output on PWM_BL
i=0;
while(i<1000)
{
i++; /* for low time of 16.8usec (do set a scale of 200usec on scope) */
}
} /*end of for loop*/
// gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
// gioSetBit(hetPORT1, 8, 0); // output on PWM_CH
// gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
// gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
//6TH Cycle
for(l=0;l<5;l++)
{
/*start of for first loop*/
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 8, 1); // output on PWM_CH
//gioSetBit(hetPORT1, 2, 1); // output on PWM_AL
gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
i=0;
while(i<1000)
{
i++; /* for high time of 16.8usec (do set a scale of 200usec on scope) */
}
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 8, 1); // output on PWM_CH
//gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
gioSetBit(hetPORT1, 6, 1); // output on PWM_BL
i=0;
while(i<1000)
{
i++; /* for low time of 16.8usec (do set a scale of 200usec on scope) */
}
} /*end of for loop*/
// gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 8, 0); // output on PWM_CH
// gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
} /*end of while loop*/
}
/*
gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
i=0;
while(i<50)
{
i++; /* for low time of 600usec
}
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
for(k=0;k<43;k++)
{ /*start of the next for loop for AH
gioSetBit(hetPORT1, 0, 1); // output on PWM_AH
i=0;
while(i<300)
{
i++; /* for high time of 16.8usec
}
gioSetBit(hetPORT1, 0, 0); // output on PWM_BH
i=0;
while(i<300)
{
i++; /* for low time of 16.8usec */
/*end of for loop
gioSetBit(hetPORT1, 0, 0); // output on PWM_CH
i=0;
while(i<300)
{
i++; /* for low time of 600usec
}
gioSetBit(hetPORT1, 8, 0); // output on PWM_CH
gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
gioSetBit(hetPORT1, 10, 0); // output on PWM_CL
} /*termination of while(1)*/
/*for(n=0;n<5;n++)
{ start of for first loop for BH
gioSetBit(hetPORT1, 4, 1); // output on PWM_CH
i=0;
while(i<150)
{
i++; /* for high time of 16.8usec
}
gioSetBit(hetPORT1, 4, 0); // output on PWM_CH
i=0;
while(i<150)
{
i++; /* for low time of 16.8usec
}
} /*end of for loop
gioSetBit(hetPORT1, 4, 0); // output on PWM_CH
i=0;
while(i<100)
{
i++; /* for low time of 600usec (do set a scale of 200usec)
}*/
/*} /*termination of while(1)*/
/*}
/* gioSetBit(hetPORT1, 0, 0); // output on PWM_AH
gioSetBit(hetPORT1, 2, 0); // output on PWM_AL
gioSetBit(hetPORT1, 4, 0); // output on PWM_BH
gioSetBit(hetPORT1, 6, 0); // output on PWM_BL
gioSetBit(hetPORT1, 8, 0); // output on PWM_CH
gioSetBit(hetPORT1, 10, 0); // output on PWM_CL */
after playing the code at no load(i.e. no motor is connected), the waveform appears as shown below:
but when I connect my three phase BLDC motor the output appears as shown below:
and the motors rotates with twice a jerk in a rotation. The major problem of driving at load is that as the motor rotates with jerks, a lot of things are toggling on DRV8301 for example User LED 1 & 3, FAULT LED ,
and the "POW" LED of Control Card RM48L952
Please guide me as soon as possible