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.

Timer 4 compare get interrupted



Hi everyone,

I have a problem when I use Timer 4 in compare mode. The problem is that it gets interrupted by the BLE stack and that make the output frequency change.

I generate a 2.7kHz square wave, but each 75ms (which is my advertising period), the timer compare will be delayed by 550us.

It appears the BLE as priority over the timer 4. Does anyone know how to fix this? My square is used to control a buzzer and this "glitch" at every 75ms create some artefact in the sound that are really anoying.

Best regards,

Jerome

  • I take it you have an interrupt handler which is reloading the timer on every compare event?

    Have you tried configuring the timer in modulo mode (counts from 0 to T4CC0) and setting the compare value to toggle at a value between 0 and T4CC0? This way no processor intervention should be required once the timer has been started.

  • Hi,

    My timer is in up/down mode, with clear output on compare/up and set on compare/down. There's no interrupt handler in my code. Everything should be done by hardware.

    I just tried with the modulo/toggle combination, same result....

  • Is there any chance your system is going into low power mode? If so the main oscillator would be disabled and the timer would stop.

  • Hi, I also thought of that issue and I disabled the power_saving flag so the system will not go in sleep mode.

    Keep in mind that the delay is precisely when the advertising data is sent, it is directly related to the BLE stack.

    I think the Bluetooth hardware use the CPU and it has supreme priority over everyone... I'm pretty sure I have no choice but to add another chip that would generate this oscillation.