MPC5777C - Central aligned pwm output code snippet

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

MPC5777C - Central aligned pwm output code snippet

3,513 Views
narasimhaugra
Contributor II

 Hi

Can I get the code snippet of thus this task:

1. Task timer 1 ms
2. Center aligned PWM Output (2 channels), synchronization at the boundary of each cycle
3. Input Pulse Measurement : On time and period of each cycle

Best, 

Ugra

Tags (1)
0 Kudos
3 Replies

1,060 Views
Perkinsw436
Contributor I

This code snippet demonstrates how to configure and use the central-aligned PWM output on the MPC5777C microcontroller. The configurePWM() function sets up the PWM module and channels for central-aligned operation. You can modify the configuration parameters according to your specific requirements.

#include "MPC5777C.h"

// Configure PWM channels for central-aligned operation
void configurePWM()
{
// Enable the PWM module clock
MC_ME.RUN_PC[0].R = 0x000000FE; // Enable PIT and PWM module clocks

// Configure PWM channel 0
PWM_0.MCTRL.B.CLK_SEL = 0; // Use the peripheral clock as the PWM timebase
PWM_0.MCTRL.B.HALF = 0; // Full cycle mode
PWM_0.CCTRL[0].B.POL = 0; // Output active high
PWM_0.CCTRL[0].B.CE = 0; // Disable event trigger for PWM channel 0
PWM_0.FCTRL[0].B.FIE = 0; // Disable fault interrupt for PWM channel 0
PWM_0.FCTRL[0].B.FSAFE = 0; // Enable immediate fault protection for PWM channel 0
PWM_0.DTCNT0[0].B.DT = 0; // No dead-time insertion for PWM channel 0
PWM_0.OUTEN.B.EN_OUT = 1; // Enable the PWM output

// Configure PWM channel 1 (if required)
// ...

// Configure PWM channel 2 (if required)
// ...

// Configure other required PWM channels

// Set the period and duty cycle for PWM channel 0
PWM_0.VAL[0].R = 1000; // Set the period (e.g., 1000 cycles)
PWM_0.CVAL[0].R = 500; // Set the duty cycle (e.g., 50% duty cycle)
}

int main()
{
// Initialize the microcontroller and other modules

// Configure the PWM channels for central-aligned operation
configurePWM();

while (1)
{
// Main application logic

// Update the duty cycle of the PWM channel if required
// PWM_0.CVAL[0].R = new_duty_cycle_value;

// Other tasks
}

return 0;
}

 

0 Kudos

3,492 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @narasimhaugra ,

Are you trying to achieve this functionality in a Simulink model?

Marius

0 Kudos

3,469 Views
narasimhaugra
Contributor II

Hi Mariusluciananad,

Yes am trying on Simulink 

 

Ugra

0 Kudos