This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2538: gptimer in pwm mode

Part Number: CC2538


Hi.
Is it possible to configure GPTimer in PWM mode without interrupts?
From datashet it seem's possible, but does not work in my case.
I am trying to setup one of the pin to generate sample rate clock for external ADC.
Usually with another mcu it is possible.

The code is here:

SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT0); 
*(unsigned long*)IOC_PA3_SEL = IOC_MUX_OUT_SEL_GPT0_ICP1;
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_CTL) = 0x00000000;
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_CFG) = 0x00000004; 
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_TAMR) = (1UL<<10)|(1UL<<11)|(1UL<<3)|(0UL<<2)|2UL; 
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_CTL) |= (1UL<<6); 
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_TAILR) = 5000; //osc clock 16MHz, so the period is 3200 Hz
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_TAMATCHR) = 1000; 
*(unsigned long*)(GPTIMER0_BASE + GPTIMER_CTL) |= 1UL;

I use IAR IDE.

  • Hi Roman,

    Yes, PWM mode is described in Sections 11.3.2.4 and 11.4.4 of the User's Guide. You can also refer to 1.3.5.4 for CCP pins.

    Regards,
    Ryan
  • Hi, Ryan.

    Thank you! 

    Your answer encouraged me to find a solution that works.

    Here is the additinal code for pin initialisation, that could be usufull for someone else:  

    *(unsigned long*)IOC_PA3_OVER = 0x0C; //output and pull-up enabled
    *(unsigned long*)(GPIO_A_BASE + GPIO_O_AFSEL) |= (1UL<<3);//enable peripheral control

    Best regards, 

    Roman