newbie Q - getting data from one code area to another

May 27, 2004 8 Replies

AVR mega16 uC / ICCAVR compiler



On reset, I run bootloader code, then I jump to the main application. When doing so, I want to store two bytes of data from the bootloader for use in the main code.



It seems that the easy solution probably lies in an area I have virtually no knowledge of, assembly language (I use C and compile with ICCAVR), and direct use of registers.



Advice?



Thanks, Scott Kelley


Re-ask that question on the newslist of Imagecaft. The link to is findable on the imagecarft website. The list is very fast and accurate. You need it anyway.

Rene

Ing.Buero R.Tschaggelar - http://www.ibrtses.com & commercial newsgroups - http://www.talkto.net

Is there a reason this question is not appropriate here? This is a far more active list.

Get the docs and learn. One should really learn the assembly language for those times when the compiler doesn't generate the code you wanted.

There may be some more using the same compiler that have experienced the same problems. But you're right, some imagecraft users *may* have a look here too.

As to your question, you have to define a memory location that is accessible by the bootloader as well as from your application and store there. I'm not familiar on the exact details of such an adressing.

Rene

Ing.Buero R.Tschaggelar - http://www.ibrtses.com & commercial newsgroups - http://www.talkto.net

I'll happily do the homework, but I'm hoping for some direction as to what is the best method for doing this so that I know what it is that I need to learn about.

Is there a reason that this CANNOT be done using registers (I have NO experience with directly addressing registers), or a reason that it is better done with eeprom (downside is additional code in both apps)?

Scott Kelley

I always favoured the books by Leventhal for most of the processors that I learned assembly for (6066, 6809 [6309], and 68000. I don't know if there are books that follow a similar style for the processor you are interested in.

I base most of my code on Virtual Stack Machines (hence Forth) which may use registers or memory to manage stack operations.

******************************************************************** Paul E. Bennett .................... Forth based HIDECS Consultancy ..... Mob: +44 (0)7811-639972 .........NOW AVAILABLE:- HIDECS COURSE...... Tel: +44 (0)1235-811095 .... see http://www.feabhas.com for details. Going Forth Safely ..... EBA. www.electric-boat-association.org.uk.. ********************************************************************

What's the problem? The contents of the SRAM, EEPROM, and registers should remain unchanged when jumping from the boot loader section to the application code. There's nothing magic about that particular jump as opposed to any other; for everything except the SPM and LPM instructions, the boot loader section is just another chunk of ROM functionally equivalent to the application section.

If your memory is being blown away, I think it's a "feature" of your compiler - look at the assembly it generates and see if it's doing something weird.

He's talking about C, you're talking about ASM.

Rene

Ing.Buero R.Tschaggelar - http://www.ibrtses.com & commercial newsgroups - http://www.talkto.net

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required