There have been a lot of requests from customers on how to use the GPTimers to generate PWM outputs on the CC26XX.
With the complexity of the devices and the power management being handled by TI RTOS this can be a bit complex and we have therefore made a PWM driver and a GPTimer driver that is posted to this thread.
These drivers will work with TI RTOS >= 2.13.00.06 and will be officially included in the TI RTOS February release (unfortunately we were to late for the December release).
Features GPTimer driver
- Support for both split (16+8 bits) and concatenated mode (32-bit) timer usage giving you up to 8 (or 4) timers in total
- Modes
- Oneshot mode
- Periodic mode
- Edge count - capture and count number of input edges from pins (falling, rising or both)
- Edge time - capture and store time when input edge occured (falling, rising or both)
- PWM
- Set load and match value of timers
- Built-in power management
- Interrupt generation for match, capture and timeout
- Debug stall - halt the timer when the debugger halts
Features PWM driver
- Generates up to 8x PWM ouputs
- Configurable period in microseconds, Hertz or raw timer counts
- Configurable duty cycle in microseconds, fraction of period or raw timer counts
- Duty and period can be changed at run-time
- Configurable Idle level (output stops at this level when timer is not running)
None of the timers support DMA at the moment as this requires changes to the current DMA driver.
Usage
- Add the necessary hardware descriptors, objects and configuration to your board files as shown in Board.c/h.
- Add a compiler search path to the drivers base or add the drivers to your TI RTOS installation
- Add the driver source to your workspace
- Follow the examples included (main_*.c)
Let us know if you have any questions / feedback in this thread and we will try our best to help out!
4760.gptimer_pwm_cc26xx_cc13xx.zip
Update 2015-12-17: Modified timer driver to compile in CCS without enabling C99 mode
Update 2016-02-16 : Needed modification for using PWM/GPTimer driver with TI-RTOS version >=2.15, red font : original content ; green font : updated content
1. GPTimerCC26XX.h
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
to
#include <ti/drivers/Power.h>
#include <ti/drivers/power/PowerCC26XX.h>
2. change Power_SB_DISALLOW to PowerCC26XX_SB_DISALLOW in GPTimerCC26xx.c
3. For board.c, change the following
{.baseAddr = GPT0_BASE, .intNum = INT_TIMER0A, .intPriority = (~0), .powerMngrId = PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
{.baseAddr = GPT0_BASE, .intNum = INT_TIMER0B, .intPriority = (~0), .powerMngrId = PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
to
{.baseAddr = GPT0_BASE, .intNum = INT_GPT0A, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0A, },
{.baseAddr = GPT0_BASE, .intNum = INT_GPT0B, .intPriority = (~0), .powerMngrId = PowerCC26XX_PERIPH_GPT0, .pinMux = GPT_PIN_0B, },
4. PWMCC26XX.c, you can either comment out the log_error or just change the duty/period to dutyValue/periodValue if you got compile error.
Regards,
Svend