Board: DUE.
I make some loops to make waveforms, but the time to execute depend on the code (for predelay) before the loops that make the waveforms.
The waveform consist of two pulses, width 3.5uS and delayed nominal 12uS, so there are tree loops.
When the 4 lines with extra delay in the start is inactive, the pulsewidth of the first pulse is 2.2uS, the second pulsewidth is 2.5uS and time from front to front is 15.1uS.
With the predelay active: 1.: 3.7uS width, 2.: 3.45uS and front to front: 12.1uS.
Can someone explain the reason?
If the compiler make different codes, I think, that I could see it in an assembler list, but I do'nt know how to make assemblerlist in IDE 1.8.5.
Can someone help?
The code is:
void MakeNorthBurst()
{
// for (int ii = 0; ii < 100; ii++) //Extra pause before. ~8uS
// {
// PIOD->PIO_ODSR = 0;
// }
for (byte i = 0; i < 12; i++) //12 pulspair
{
for (byte ii = 0; ii < 27; ii++) // 1. pulse
{
PIOD->PIO_ODSR = Sin2table[PulsTablePtr][ii];
}
for (byte ii = 0; ii < 77; ii++) //Pause between pulse
{
NOP; // delay 12ns on a 84MHz DUE
}
for (byte ii = 0; ii < 27; ii++) // 2. pulse
{
PIOD->PIO_ODSR = Sin2table[PulsTablePtr][ii];
}
}
}
Or, you can show verbose output during compilation and copy the compile command. Then add -S and change the output file name.
You also have to remove the -flto to get human readable output.
No, but I saw the same issue when generating tones with delays on the DUE.
Arbitary changes in the code, which would only affect the position of the tone routines in memory and not the tone code itself, could make the delays (used to generate the tones) vary, easy to see as jitter in the tone on a scope.
I did eventually get the code to produce clean consistent tones by putting arbitary bits of code in front of the tone routines, but I never found the reason for the problem.
I did post a query about it, but I guess everyoen assumed it was 'a problem with the code'.
I recently updated to version 1.8.5. Now, the verbose output screen tells me what the commands are doing. It says, "Compiling the sketch..." and the next line is the command that compiles my sketch. That's the one I want. Then it says, "Compiling libraries..." etc.
I find that the first time I build it, there is a ton of output. If I build it again immeditately, there's not as much for me to sort through.