Some questions in the PWM project ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Some questions in the PWM project ?

Jump to solution
1,841 Views
15219661324
Contributor III

Hi,

   When reading the PWM project, I have some questions:

   (1)What does the following code do? Some people say they are trying to turn off the fault protection? If so, I want to know how do they work?

/* Set the PWM Fault inputs to a low value */
XBARA_Init(XBARA1);
XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm1Fault0);
XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm1Fault1);
XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm1234Fault2);
XBARA_SetSignalsConnection(XBARA1, kXBARA1_InputLogicHigh, kXBARA1_OutputFlexpwm1234Fault3);

   (2)What's the difference between signed center-aligned and unsigned cente-alignes ? 

   (3)What's the difference between signed edge-aligned and unsigned edge-aligned ? 

/*! @brief PWM operation mode */
typedef enum _pwm_mode
{
kPWM_SignedCenterAligned = 0U, /*!< Signed center-aligned */
kPWM_CenterAligned, /*!< Unsigned cente-aligned */
kPWM_SignedEdgeAligned, /*!< Signed edge-aligned */
kPWM_EdgeAligned /*!< Unsigned edge-aligned */
} pwm_mode_t;
0 Kudos
Reply
1 Solution
1,707 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello ,

Hope you are doing well.

  (1)What does the following code do? Some people say they are trying to turn off the fault protection? If so, I want to know how do they work?

The intended application of the Inter-Peripheral Crossbar Switch (XBAR) module is to provide a flexible crossbar switch function that allows any input (typically from external GPIO or internal module outputs) to be connected to any output (typically to external GPIO or internal module inputs) under user control. This is used to allow user configuration of data paths between internal modules and between internal modules and GPIO. With that code you are setting the PWM channels to a positive logical level, this way when the trigger condition of the PWM occurs the channel will go to a High State. If you comment these lines then when the trigger condition of the PWM occurs nothing will happen, the channel will stay on the same logical level. Please refer to this thread for more details PWM on i.MX RT 1050 EVKB

(2)What's the difference between signed center-aligned and unsigned center-aligned ? 

This is an example of a center aligned PWM signal. The signed range of integer values that can be stored in 16 bits is −32,768 (−1 × 215) through 32,767 (215 − 1); the unsigned range is 0 through 65,535 (216 − 1).

pastedImage_6.png

(3)What's the difference between signed edge-aligned and unsigned edge-aligned ? 

The difference is the same as the above answer. Please see the image for an example of edge aligned signals. 

pastedImage_10.png

Please refer to reference manual for further details on the PWM.

Hope it helps!

Sabina

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

View solution in original post

2 Replies
1,708 Views
Sabina_Bruce
NXP Employee
NXP Employee

Hello ,

Hope you are doing well.

  (1)What does the following code do? Some people say they are trying to turn off the fault protection? If so, I want to know how do they work?

The intended application of the Inter-Peripheral Crossbar Switch (XBAR) module is to provide a flexible crossbar switch function that allows any input (typically from external GPIO or internal module outputs) to be connected to any output (typically to external GPIO or internal module inputs) under user control. This is used to allow user configuration of data paths between internal modules and between internal modules and GPIO. With that code you are setting the PWM channels to a positive logical level, this way when the trigger condition of the PWM occurs the channel will go to a High State. If you comment these lines then when the trigger condition of the PWM occurs nothing will happen, the channel will stay on the same logical level. Please refer to this thread for more details PWM on i.MX RT 1050 EVKB

(2)What's the difference between signed center-aligned and unsigned center-aligned ? 

This is an example of a center aligned PWM signal. The signed range of integer values that can be stored in 16 bits is −32,768 (−1 × 215) through 32,767 (215 − 1); the unsigned range is 0 through 65,535 (216 − 1).

pastedImage_6.png

(3)What's the difference between signed edge-aligned and unsigned edge-aligned ? 

The difference is the same as the above answer. Please see the image for an example of edge aligned signals. 

pastedImage_10.png

Please refer to reference manual for further details on the PWM.

Hope it helps!

Sabina

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

----------------------------------------------------------------------------------------------------------------------- 

1,707 Views
15219661324
Contributor III

The crossbar has to be set up to get the fault inputs in the correct state else they inhibit the PWM output, that cuaght me out at first. You can get round it if you dont want the fault inputs. You can get round that by configuring the fault handling on the PWM channel and in that case you dont need to configure the crossbar, something like this:

 

pwm_fault_param_t faultParam;

PWM_Type *base = BOARD_PWM_BASEADDR;


// disable the fault inut monitoring
base->SM[kPWM_Module_3].DISMAP[0] = 0;
base->SM[kPWM_Module_3].DISMAP[1] = 0;

 

faultParam.faultClearingMode = kPWM_Automatic;
faultParam.faultLevel = true;
faultParam.enableCombinationalPath = false;
faultParam.recoverMode = kPWM_RecoverHalfAndFullCycle;

PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_0, &faultParam);
PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_1, &faultParam);
PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_2, &faultParam);
PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_3, &faultParam);

Hello, 

I found that just the following two lines of code can also set the PWM output correctly.

PWM_Type *base = BOARD_PWM_BASEADDR;

base->SM[kPWM_Module_3].DISMAP[0] = 0;

So, I wonder if any other code is necessary in the example you gave.

pwm_fault_param_t faultParam;
base->SM[kPWM_Module_3].DISMAP[1] = 0;

faultParam.faultClearingMode = kPWM_Automatic;
faultParam.faultLevel = true;
faultParam.enableCombinationalPath = false;
faultParam.recoverMode = kPWM_RecoverHalfAndFullCycle;

PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_0, &faultParam);
PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_1, &faultParam);
PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_2, &faultParam);
PWM_SetupFaults(BOARD_PWM_BASEADDR, kPWM_Fault_3, &faultParam);

Thanks!

0 Kudos
Reply