Hello engineers,
I am trying to generate a high-frequency PWM signal using Timers 1 and 3 on the CC2541. Above 20kHz is required because below that is audible and very irritating :)
I programmed timers 1 and 3 to generate 32 and 64 kHz respectively, which works, I get a stable pwm signal on the oscilloscope. However, the BLE performance suffers tremendously. I am transferring the duty cycle of both signals over BLE, at approximately 30-50 Hz. This works very well when PWM frequency is 500 Hz for both timers. However, when I change the pwm freq to 32 kHz, there is significant lag between me sending a dutycycle change (a slider on the app) and the change actually happening on the device. The lag is of the order of several seconds.
I have tried reducing the 'active clock tick' by using a scaler (e.g. for Timer 1, /4 scaling and modulo mode with ch0 = 256, giving 32 kHz), but this seems to have no effect. It seems what is causing the sluggishness is the frequency at which the GPIO is toggled.
So I would like to ask:
- how many clock ticks does it take to toggle a GPIO set to timer output?
- What is the most efficient way to generate a 32 kHz pwm signal with 7 or 8bit dutycycle resolution?
- Is it normal that generating 2 or 3 signals at 32 kHz will cause BLE performance to become so sluggish that it can't transfer a few bytes every 20 ms?
Thanks in advance!