EmbDev.net

Forum: µC & Digital Electronics Arduino code not able to upload twice


von Caroline Hein (Guest)


Attached files:

Rate this post
0 useful
not useful
Hi everyone,
I am currently writing my bachelor thesis in Denmark (but am from 
University of Freiburg) and am getting no help or support at all here 
and can't find the probelm in my code.  I program a weather station for 
an indoor room with the enclosed code that worked just fine with the 
Arduino MKR1000.  However if I use the same code the next day or a few 
hours later, it doesn't work anymore ... I always have coded exactly the 
same thing all over again and it only worked once, that is now the 5th 
time already .. does anyone have any idea where the problem could be?
I send data over WiFi to a server called Blynk.  The
 Sample code form the library still works but mine only ever once ... I 
tried restarting and installing everything new, changing computer, 
controllers and cables but nothing worked

Thank you very much for any help!
-Caroline

von stefanus (Guest)


Rate this post
0 useful
not useful
So you got it working multiple times but say that it works only once. 
What did you do to start over successfully? Did you replace the Arduino 
board by a new one?

Looking at the schematics I can see that the USB interface is controlled 
by the main microcontroller (ATSAMW25H18), which is the one that 
executes your sketch. So a faulty sketch might block the USB interface.

It might help to press the Reset button immediately before transferring 
the program. If that does not work, then try to hold the reset button 
while plugging in the USB cable. Continue to hold the reset button until 
the file transfer starts, so your own sketch does not get a chance to 
start and brick the USB interface.

If that does both not help, then you may use the SWD interface J3 
instead to transfer the program. But then you need a suitable 
programming adapter. Be sure to buy one that is supported by the Arduino 
IDE.

von stefanus (Guest)


Rate this post
0 useful
not useful
Looking into your source code I see a major issue:

*.h files (in this case functions.h) should not contain executable code. 
Only the headers of function belong into *.h files. The executable code 
belongs into *.c files.

But this is possibly not the reason of your current problem.

von Caroline Hein (Guest)


Rate this post
0 useful
not useful
Thank you very much for all the help!! I tried everything in order you 
suggested and the reset button pressing the whole time when connecting 
and then immediately uploading the code worked. Seems like the code is 
blocking the USB port somehow, thank you so much!

von stefanus (Guest)


Rate this post
0 useful
not useful
Thanks for your replay. I'm happy that I could help you although I did 
never use that Board myself :-)

Some of your libraries may contain blocking wait loops which may affect 
the USB port. In traditional Arduino boards, that is harmless. But since 
we have microcontrollers with internal USB and WiFi we need to be 
careful using loops. You are on the safe side when your loop() function 
runs a bit less than 1ms per call in worst case.

If you find it difficult to avoid using delay() and wait loops in your 
own code, search for instructions about "finite state machines on 
microcontrollers".

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig