Unwanted delays after serial output - mod5282

Discussion to talk about software related topics only.
Post Reply
ShawnR
Posts: 2
Joined: Tue May 01, 2012 11:18 am

Unwanted delays after serial output - mod5282

Post by ShawnR »

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:

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
You can see it happening here:
Timing with no OSLock
Timing with no OSLock
nolock.png (10.43 KiB) Viewed 2037 times

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
Shows timing of OSUnlock
Shows timing of OSUnlock
oslock.png (10.35 KiB) Viewed 2037 times
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.
Last edited by ShawnR on Wed May 02, 2012 11:15 am, edited 1 time in total.
ShawnR
Posts: 2
Joined: Tue May 01, 2012 11:18 am

Re: Unwanted delays after serial output - mod5282

Post by ShawnR »

Found the problem not 10 minutes after making the post. I wasn't rebuilding the system libraries fully. Increasing TICKS_PER_SECOND decreased the delay in OSUnlock.
Post Reply