Basic eFlexPWM Setup in mc56f82748

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

Basic eFlexPWM Setup in mc56f82748

570 Views
kienfrancis_ure
Contributor II

Hi. I used this codes below to setup a basic pwm and a current reset pwm based on an example code. But I can't get an output PWM in PWM0A/GPIOE1. Thanks for the help!

Basic PWM


PWMA_SM0INIT=0xF000;
PWMA_SM0CTRL2|=0x2000;
PWMA_SM0CTRL|=0X0470;
PWMA_SM0VAL0=0x0000;
PWMA_SM0VAL1=0x7FFF;
PWMA_SM0VAL2=0x0000;
PWMA_SM0VAL3=0x3E80;
PWMA_OUTEN|=0x0100;
PWMA_MCTRL|=0x0001;
PWMA_MCTRL|=0x0100;

and

/* ###################################################################
** Filename : main.c
** Project : eFlexCR
** Processor : MC56F82748VLH
** Version : Driver 01.16
** Compiler : CodeWarrior DSP C Compiler
** Date/Time : 2019-03-26, 11:49, # CodeGen: 0
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** ###################################################################*/
/*!
** @file main.c
** @version 01.16
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup main_module main module documentation
** @{
*/
/* MODULE main */


/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "Pins1.h"
/* Including shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "Init_Config.h"
#include "PDD_Includes.h"

unsigned int turnon;


void main(void)
{
/* Write your local variable definition here */

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/

CMPA_DACCR=0X0085;/*enable the comparatorA DAC control and set the DAC output to 0.3V */
CMPA_CR0=0X0000; /*disable comparator and internal hysteresis */
CMPA_CR1=0X0014;
CMPA_FPR=0X0;
CMPA_CR1=0X0001;
CPU_Delay100US(1);
XBARA_SEL12=0X0A;/* Set CMPA_OUT as EXT_SYNC of eFlexPWM sub-module0 by crossbar */
/* Configure sub-module0 as current-reset PWM mode wiht initial 1kHz frequency */
PWMA_SM0INIT=0x8AD0;
PWMA_SM0CTRL2=0X2300;/*SET PWMA as independent and external sync to initialize */
PWMA_SM0CTRL=0X0400;/*FULL CYCLE RELOAD*/
PWMA_SM0VAL0=0;
PWMA_SM0VAL1=0x752F;
PWMA_SM0VAL2=0x8AD0;
PWMA_SM0VAL3=0x8AD0;
PWMA_SM0DISMAP0=0x0FF0;
PWMA_OUTEN=0X0100;
PWMA_DTSRCSEL=0X00;
PWMA_MCTRL=0X0001;
PWMA_MCTRL=0X0100;

for(;;) {
turnon = 300; /* 5us: 300/60=5 */
PWMA_SM0VAL3=(-30000+turnon-1); /* Set Value 3 register to output programmed 20us high level for PWM0A: VAL2=0x8AD0U=-30000 */
PWMA_MCTRL=0X0001; /* Reload duty cycle */
}
}


/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.3 [05.09]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/

Tags (2)
0 Kudos
1 Reply

458 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Kien,

I attach the example of eFlexPWM module based on MC56F82748, pls refer to it.

Hope it can help you

BR

Xiangjun Rong

0 Kudos