Go Down

Topic: Memory Allocation (Read 1 time) previous topic - next topic

chiru42

Hey Folks,

1. I'm having a doubt, where does the program downloaded to Arduino go and sit in the memory?
2. I understand that evry time we download a new program into the Arduino, it will go overwrite the old program and make a seat for it in the memory. Am I correct?
3. Is there any possibility to store two different programs in different memory locations of Arduino and let them exectute one after the other during operation?

can somebody help me with this stuff?


thnx,
chiru
chiru

Coding Badly


Hey,

1. I'm having a doubt, where does the program downloaded to Arduino go and sit in the memory?


I don't understand.

Quote
2. I understand that evry time we download a new program into the Arduino, it will go overwrite the old program and make a seat for it in the memory. Am I correct?


Correct.

Quote
3. Is there any possibility to store two different programs in different memory locations of Arduino and let them exectute one after the other during operation?


Yes.  That's exactly how the bootloader works.

chiru42

But bootloader is like unaccessble part of a program sitting and doing its work in the controller. Like-wise can i make my sketch into two parts so that part -1 runs first and then part-2
chiru

AWOL

Quote
like-wise can i make my sketch into two parts so that part -1 runs first and then part-2

Yes, they're called "functions".
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

westfw

Quote
Is there any possibility to store two different programs in different memory locations of Arduino and let them exectute one after the other during operation?

Theoretically possible, but not "easy" and not within the Arduino environment.
And you'd need essentially a third program to figure out which of the other two to run, and when.  An "operating system."

I think "bitlash" can do this for it's interpreted "programs."
FORTH can do it.  sort of.

chiru42

can i try this way?, i shal define my two programs in different functions and can i terminate the program as and when i needed?( i would give a condition, if it reached, second function will execute else terminate the complete program).
chiru

retrolefty


can i try this way?, i shal define my two programs in different functions and can i terminate the program as and when i needed?( i would give a condition, if it reached, second function will execute else terminate the complete program).


Sure. However you can never truly 'terminate' the complete program, but what you would do would be to perform the statements to cause the program to run an endless do nothing loop and doing nothing but looping until the chip is reset or powered off and on. there is no halt instuction in the AVR machine language.

while(1) { }    that is an example of a do nothing loop that won't stop until the chip is reset or power cycled.



chiru42

that would be helpful. i shall try this way. thnq Lefty.
    Now one moe thing i should worry about is, is there any way that i cut run two sections parallelly?

Let me put it in  this way, section-1 would get the data from sensors and go after some mathematical calculations and repeat the same.
    section-2 would print the results obtained from section-1 on serial moniter and output some through the pins.

Its not an issue even if its not the current data. its ok even if it can communicate the past data through section-2
chiru

retrolefty


that would be helpful. i shall try this way. thnq Lefty.
    Now one moe thing i should worry about is, is there any way that i cut run two sections parallelly?

Let me put it in  this way, section-1 would get the data from sensors and go after some mathematical calculations and repeat the same.
    section-2 would print the results obtained from section-1 on serial moniter and output some through the pins.

Its not an issue even if its not the current data. its ok even if it can communicate the past data through section-2



I think you are thinking wrong about 'sections' and 'programs'. It's very possible and desirable to think about just one overall program, the sketch, that can do all though tasks at the proper time all under your single program's control. It's called program structure and the programming language gives you all the commands needed to structure the control of your one large program that performs as many different task when and only when you need them to be performed.

You limiting your thinking and learning with this seperate programs/sections and running them parallelly.

Lefty

chiru42





You limiting your thinking and learning with this seperate programs/sections and running them parallelly.




let us forget about sections. could u plz tell me if i could get things done parallelly in a single program? becoz the execution time is crucial for me

chiru
chiru

cyclegadget






You limiting your thinking and learning with this seperate programs/sections and running them parallelly.




let us forget about sections. could u plz tell me if i could get things done parallelly in a single program? becoz the execution time is crucial for me

chiru


It depends on what functions you are try to run. Examples: Pins can maintain status while other actions occur.  However, some things like writing to an SD card need a small block of time to complete. Serial communications requires a bit of time to complete. You can blink many LEDs on an off so, quickly that they appear to be lit continuously.

Most of the time the processors runs so quickly, that the user can not perceive any delay between actions. 
Good links: Eagle tutorial= http://www.youtube.com/playlist?list=PLDE1858BD83D19C70
General Arduion tutorials = http://tronixstuff.wordpress.com
http://www.gammon.com.au/forum/bbshowpost.php?bbtopic_id=123

kf2qd

It sounds like you are trying to aquire some data, manipulate it and then output the results. That could be considerred 3 main steps -

You would write 3 functions


void getdata() {
}

void manipulatedata() {
}

void outputdata() {
}

and inside of loop you would do something like this

void loop() {

   whatever code needs to run before you aquire data or to time the data aquisition..   

   getdata;
   manipulatedate;
   outputdata;
   

   other code you want to run..
}


AWOL

Quote
let us forget about sections. could u plz tell me if i could get things done parallelly in a single program? becoz the execution time is crucial for me

You keep going on about that, but you never specify in what way it is critical, or by how much you're missing the mark.
Until you come up with specifics (code, timings and specifications), you're just wasting everyone's time.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Osgeld

Quote

You keep going on about that, but you never specify in what way it is critical, or by how much you're missing the mark.
Until you come up with specifics (code, timings and specifications), you're just wasting everyone's time.


exactly, even if it was executed in parallel your using a single processor, and multitasking is really just an illusion of switching priorities, even in multicore super nasty high speed computers of today, its sharing resources and must wait in que at some point.
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Go Up