time it takes to allocate ram

not quite sure if its the right wording in the ^title^ but i have a project with 1000+ lines of code and this needs lots of variables of all sorts set up and it seems on a serial connect there is about a 5 second wait before it comes live but if i just press reset it is only 2 or so seconds. im guessing the serial reset causes a boot-loader wait but i could be completely wrong.

any input would be very helpful. :slight_smile:

matty

matthewellis:
it seems on a serial connect there is about a 5 second wait before it comes live

What is a serial connect? Is it opening the arduino serial monitor? If reset takes 2 seconds, then what does it do at the end of the 2 second that makes you think it started or came alive? You have not provided any details of your program. You won't get much help from here. It like you describing a few symtoms of your kid's sickness but don't actually bring the kid to the doctor.

any input would be very helpful

To be able to help any code posted would be very helpful :wink:

im guessing the serial reset causes a boot-loader wait but i could be completely wrong.

Yes, opening a serial port resets the Arduino. The Arduino then needs to determine if it was reset because new code is to be sent, or not. It does this my monitoring the serial port (in the bootloader) for a known stream of data. If that data does not arrive in a reasonable period of time, it assumes that it will never arrive, and continues booting.

matthewellis:
i have a project with 1000+ lines of code and this needs lots of variables of all sorts set up and it seems on a serial connect there is about a 5 second wait before it comes live but if i just press reset it is only 2 or so seconds

What board? What code?

I just tested my Uno with the Blink sketch. Plugging in the USB port (to power it up) makes the LEDs blink within a fraction of a second. Opening the serial monitor seems to stall it for around a second or possibly less. A bit would depend which bootloader you have.

To answer the thread subject header, RAM is allocated very quickly. After all, the vast majority of code accesses RAM, so it is accessed within the time taken for the relevant instruction to execute.