Post Go back to editing

Timer Config ADUCM3029

Hello. I have a simple code below that generate PWM with GP2 Timer2 Config and uses the GPIO33 pin of the ADUCM3029. Well, can you help me to configure the code that instead of usingTimer2 it will use the Timer1 (GPIO27 pin of the IC). I'm bit confused on how the pinmux map on physical IO pins with the GP Timers. Any help would be very appreciated. Thanks


#include <common.h>
#include <drivers/pwr/adi_pwr.h>
#include <drivers/tmr/adi_tmr.h>

#define GP2_LOAD_VALUE_FOR_60HZ 27084 // load value: (16.667ms / (1/26MHz * 16))

#define TIMER2_TIMER2_OUT_PORTP2_MUX  ((uint16_t) ((uint16_t) 2<<2))

void GP2CallbackFunction(void *pCBParam, uint32_t Event, void  * pArg)

int main()

  ADI_TMR_CONFIG        tmrConfig;
  ADI_TMR_RESULT        eResult;
  ADI_TMR_PWM_CONFIG   	pwmConfig;


  adi_pwr_SetClockDivider(ADI_CLOCK_HCLK, 1u);
  adi_pwr_SetClockDivider(ADI_CLOCK_PCLK, 1u);

  *((volatile uint32_t *)REG_GPIO2_CFG) = TIMER2_TIMER2_OUT_PORTP2_MUX;

  adi_tmr_Init(ADI_TMR_DEVICE_GP2, GP2CallbackFunction, NULL, true);

  /* GP timer configuration */
  tmrConfig.bCountingUp  = false;
  tmrConfig.bPeriodic    = true;
  tmrConfig.ePrescaler   = ADI_TMR_PRESCALER_16;
  tmrConfig.eClockSource = ADI_TMR_CLOCK_HFOSC;
  tmrConfig.nLoad        = GP2_LOAD_VALUE_FOR_60HZ;
  tmrConfig.nAsyncLoad   = GP2_LOAD_VALUE_FOR_60HZ;
  tmrConfig.bReloading   = true;
  tmrConfig.bSyncBypass  = false;

  eResult = adi_tmr_ConfigTimer(ADI_TMR_DEVICE_GP2, &tmrConfig);
  DEBUG_RESULT("Error configuring GP2 PWM.", eResult, ADI_TMR_SUCCESS);

  /* timer PWM configuration */
  /* Configure GP2 PWM0 to have a PWM duty cycle of 50% */
  pwmConfig.eOutput      = ADI_TMR_PWM_OUTPUT_0;
  pwmConfig.bMatch       = true;
  pwmConfig.bIdleHigh    = false;
  pwmConfig.nMatchValue  = (uint16_t) (GP2_LOAD_VALUE_FOR_60HZ / 2);
  eResult = adi_tmr_ConfigPwm(ADI_TMR_DEVICE_GP2, &pwmConfig);
  DEBUG_RESULT("Error configuring GP2 PWM.", eResult, ADI_TMR_SUCCESS);

  /* GP timer enable */
  eResult = adi_tmr_Enable(ADI_TMR_DEVICE_GP2, true);
  DEBUG_RESULT("Error configuring GP2 PWM.", eResult, ADI_TMR_SUCCESS);