The communication involved in uploading code to the board happens during the bootloader section well before any of your code runs.
However this question lacks context and is far too vague to give any real answer. There are indeed things you can do in your code that will stop you from being able to upload new code. It isn't clear from the one line you've provided whether or not you're doing that.
Delta_G:
The communication involved in uploading code to the board happens during the bootloader section well before any of your code runs.
However this question lacks context and is far too vague to give any real answer. There are indeed things you can do in your code that will stop you from being able to upload new code. It isn't clear from the one line you've provided whether or not you're doing that.
Hello,
I believe i got the answer from the post just before yours, but there:
cli();
while(1)
{
}
That is in the loop() section and in setup() there is just one variable declared.
The intent is to make a well timed program that outputs pulses at a certain time, and it will loop within the while statement forever.
But from the post before yours i see that the Nano is reset before any code is uploaded so i guess that answers that, thanks.
Programming the Arduino includes a reset and your program is no longer running at that stage.
Hi,
Oh ok thanks. I didnt want to take a chance on not being able to program the Nano again using the conventional means with the USB port.
I am not even sure if that command is needed yet (cli()) but i have read that millis() uses interrupts so i wanted to stop that from messing up the timing in the actual program code that will follow that has to output pulses at specific times.
You are correct that for fine timing, you don't want the Timer 0 interrupts to occur, but you are better off just stopping Timer 0 than disabling all interrupts.
cattledog:
You are correct that for fine timing, you don't want the Timer 0 interrupts to occur, but you are better off just stopping Timer 0 than disabling all interrupts.
Hi,
That sounds good but I am not sure how to do that in Arduino code. Any ideas?
Thanks. I guess Timer 0 is the timer used for millis() and that interferes with other program timing?
What about delayMicroseconds, does Timer 0 interfere with that too?
Yes. delayMicroseconds() uses dummy processing cycles, and because those cycles are halted while the Timer0 oveflow interrupt is executed it will be affected as well.
cattledog:
Yes. delayMicroseconds() uses dummy processing cycles, and because those cycles are halted while the Timer0 oveflow interrupt is executed it will be affected as well.
Hi,
Wow really? That does not seem like it should be that way. If we need a delay that is in microseconds the chances are that an interrupt would alter that too much such that it would mess up the timing of the signals generated using delayMicroseconds().
I might have to look into this, such as maybe looking into how some libraries are generating timing signals for IR remote controls which often have to generate a 38kHz carrier. I dont have any data though on the required accuracy of that frequency in order to communicate properly with the device being controlled.
Here's a link to an extreme case where the OP was incorrectly using a lengthy ISR in a very frequent timer interrupt which extended the delayMicroseconds() time.