Hello.
We need to periodically generate a pulse at the GPIO output of a certain duration from 20 to 500 microseconds ± 15%.
We create our application based on the simple_peripheral SDK 5.20 .
We change the output to the port directly in the timer interrupt function (the timer priority is set to the highest (1<<5)). The pulse duration is formed using CPU delay().
The moment of pulse formation is wrapped in HAL_ENTER_CRITICAL_SECTION and SysTickDisable(), but despite this, the pulse sometimes receives an addition of more than 20%, the feeling that something interferes with the process of pulse formation.
Our code:
static void pulse(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
{
SysTickDisable();
HAL_ENTER_CRITICAL_SECTION(key);
HWREGB(GPIO_BASE + TEST_PIN) = 1;
CPUdelay(3000);
HWREGB(GPIO_BASE + TEST_PIN) = 0;
HAL_EXIT_CRITICAL_SECTION(key);
SysTickEnable();
}
For us, the pulse duration is very critical, how in our case can we take 100% CPU time without breaking the application?
What are the problems with disabling interrupts for 500 µs every 10ms?
Please, give any thoughts, advice or indicate a possible direction for solving this problem!
Regards John