I am having trouble with the following lines of code on the Arduino Due:
freq_int1 = start_int_Hz;
freq_int2 = start_int_Hz;
for (int i = 0; i < num_steps; i++)
{
SPI.transfer(SLAVE, freq_int2 & 0xFF); //Transfer first byte
freq_int2>>=8;
SPI.transfer(SLAVE, freq_int2 & 0xFF); //Transfer second byte
freq_int2>>=8;
SPI.transfer(SLAVE, freq_int2 & 0xFF); //Transfer third byte
freq_int2>>=8;
SPI.transfer(SLAVE, freq_int2 & 0xFF); //Transfer fourth byte
SPI.transfer(SLAVE, 0x00); //Transfer fifth byte (all zeros for the AD9850)
REG_PIOC_SODR = 1<<21; //Pulse frequency update pin high
REG_PIOC_CODR = 1<<21; //Pulse frequency update pin low
freq_int1 = freq_int1 - freq_steps*; //change the frequency for the next iteration*
freq_int2 = freq_int1 - freq_steps*;
for(int z = 0; z < num_delay_loops; z++)
_ {_
_ //Slow down the loops execution*_
* }*
* }*
/**********************************************/
*I am using this code with the AD9850 DDS module and this is the code that updates the frequency throughout a period ramp (high to low frequency). The code itself is very efficient and works too fast for our application. Therefore, I have added in a for loop near the end with nothing in it to simply slow down the ramp (delay and delay Microseconds are too coarse). *
As it stands, this code does not work. No matter what I make num_delay_loops, or what I put in it, the code still runs just as fast. If I enclose the whole code in a while (1) loop, it works perfectly! However, if I give that while loop a termination condition (break, number of runs, etc.) it goes back to ramping really fast.
What is going on?? Does anyone have an idea as to why this happens? I greatly appreciate any help.
Thanks,
Eric