Unwanted delays after serial output - mod5282
Posted: Tue May 01, 2012 12:41 pm
I'm having a bit of an issue where I get 40ms+ delay after using the NB libraries to write to the serial port.
Part of the relevant code:
You can see it happening here:
I thought it might have something to do with context switching, so I wrapped it in OSLock/OSUnlock to stop interruptions from affecting the UART communications. This works to an extent, and the time between packets is much better, but now OSUnlock is taking 40ms to after the packet is sent, as confirmed by logic analyzer.
If you notice, there are some other small pulses on the bottom signal around the +20ms mark. OSLock/OSUnlock are being called there too, with no delay.
I'm at the point where I'm out of ideas as to how to remove this delay. I've also tried increasing (moving closer to 1) the task's priority and increasing the TICKS_PER_SECOND constant and rebuilding the system libs. None of these seem to have any effect.
Part of the relevant code:
Code: Select all
sim.gpt[0].port = 0;
serwriteaddress(fd, 0xE5);
//No delay
serwriteaddress(fd, startAddress);
//40ms delay
for(uint16_t i = 0; i < modules.size(); i++)
{
modules[i].writeRBits(fd);
}
//40ms delay
serwriteaddress(fd, 0xE6);
sim.gpt[0].port = FF;
//imediate exit
I thought it might have something to do with context switching, so I wrapped it in OSLock/OSUnlock to stop interruptions from affecting the UART communications. This works to an extent, and the time between packets is much better, but now OSUnlock is taking 40ms to after the packet is sent, as confirmed by logic analyzer.
Code: Select all
OSLock();
serwriteaddress(fd, 0xE5);
//No delay
serwriteaddress(fd, startAddress);
for(uint16_t i = 0; i < modules.size(); i++)
{
modules[i].writeRBits(fd);
}
serwriteaddress(fd, 0xE6);
sim.gpt[0].port = 0;
OSUnlock();
sim.gpt[0].port = FF;
//imediate exit
I'm at the point where I'm out of ideas as to how to remove this delay. I've also tried increasing (moving closer to 1) the task's priority and increasing the TICKS_PER_SECOND constant and rebuilding the system libs. None of these seem to have any effect.