Gtm_tom

Announcements

Webinar: Integrated solutions for smaller, simpler low-voltage motor control design.
Join the webinar to experience!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User19796
Level 1
Level 1
Hello
I am a new member, now i have project about make PWM with Pulse from 10ns to 999us and frequency from 1hz to 10khz
I was follow your example code and work base on direction. But i could not get frequency 1hz with pulse = 10ns.
can you help me correct my code. i put my code below.
thanks for your help!


#include "GTM_TOM_PWM.h"
#include "Ifx_Types.h"
#include "IfxGtm_Tom_Pwm.h"

/*********************************************************************************************************************/
/*------------------------------------------------------Macros-------------------------------------------------------*/
/*********************************************************************************************************************/
#define ISR_PRIORITY_TOM 20 /* Interrupt priority number */
#define LED IfxGtm_TOM0_2_TOUT104_P10_2_OUT /* LED which will be driven by the PWM IfxGtm_TOM0_8_TOUT0_P02_0_OUT */
#define PWM_PERIOD 100e6 /* PWM period for the TOM */




Ifx_GTM *gtm = &MODULE_GTM;
/*********************************************************************************************************************/
/*-------------------------------------------------Global variables--------------------------------------------------*/
/*********************************************************************************************************************/
IfxGtm_Tom_Pwm_Config g_tomConfig; /* Timer configuration structure */
IfxGtm_Tom_Pwm_Driver g_tomDriver; /* Timer Driver structure */
uint32 g_fadeValue = 0; /* Fade value, starting from 0 */
sint8 g_fadeDir = 1; /* Fade direction variable */

/*********************************************************************************************************************/
/*-----------------------------------------------Function Prototypes-------------------------------------------------*/
/*********************************************************************************************************************/
void setDutyCycle(uint32 dutyCycle); /* Function to set the duty cycle of the PWM */

/*********************************************************************************************************************/
/*--------------------------------------------Function Implementations-----------------------------------------------*/
/*********************************************************************************************************************/
/* This function initializes the TOM */
void initGtmTomPwm()
{
IfxGtm_enable(&MODULE_GTM); /* Enable GTM */



IfxGtm_Cmu_enableClocks(&MODULE_GTM, IFXGTM_CMU_CLKEN_FXCLK); /* Enable the FXU clock */

/* Initialize the configuration structure with default parameters */
IfxGtm_Tom_Pwm_initConfig(&g_tomConfig, &MODULE_GTM);

g_tomConfig.tom = LED.tom; /* Select the TOM depending on the LED */
g_tomConfig.tomChannel = LED.channel; /* Select the channel depending on the LED */
g_tomConfig.period = PWM_PERIOD; /* Set the timer period */
g_tomConfig.pin.outputPin = &LED;
g_tomConfig.dutyCycle = 1; /* Change the value of the duty cycle */
SerialASC.println(PWM_PERIOD);
g_tomConfig.synchronousUpdateEnabled = TRUE; /* Enable synchronous update */

IfxGtm_Tom_Pwm_init(&g_tomDriver, &g_tomConfig); /* Initialize the GTM TOM */
//IfxGtm_Tom_Pwm_start(&g_tomDriver, TRUE); /* Start the PWM */
}


void setup()
{


SerialASC.begin(9600);
analogReadResolution(12);
analogWriteResolution(12);
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
pinMode(3,OUTPUT);
digitalWrite(3, LOW);

initGtmTomPwm();

}

void loop()
{

}
0 Likes
1 Reply
Elettrograffiti
Employee
Employee
Hi! Which product are you using ?
0 Likes