EmbeddedRelated.com
Forums
Memfault Beyond the Launch

newbie Q - getting data from one code area to another

Started by Scott Kelley May 27, 2004
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
Scott Kelley wrote:

> 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?
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
Rene Tschaggelar wrote:

> Scott Kelley wrote: > >> 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? > > > 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
Is there a reason this question is not appropriate here? This is a far more active list.
>I have virtually no knowledge of, assembly language
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.
Scott Kelley wrote:

> Rene Tschaggelar wrote: > >> Scott Kelley wrote: >> >>> 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? >> >> 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. >> > > Is there a reason this question is not appropriate here? This is a far > more active list.
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

Gary Kato wrote:
>>I have virtually no knowledge of, assembly language > > > 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. >
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
Scott Kelley wrote:

> > > Gary Kato wrote: >>>I have virtually no knowledge of, assembly language >> >> >> 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. >> > > 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)?
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 ....................<email://peb@a...> Forth based HIDECS Consultancy .....<http://www.amleth.demon.co.uk/> 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.. ********************************************************************
In article <4JqdnWNNE7pLJirdRVn-uw@centurytel.net>,
Scott Kelley  <scottk@iccom.com> wrote:
>Is there a reason that this CANNOT be done using registers
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.
Terran Melconian wrote:

> In article <4JqdnWNNE7pLJirdRVn-uw@centurytel.net>, > Scott Kelley <scottk@iccom.com> wrote: > >>Is there a reason that this CANNOT be done using registers > > > 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.
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

Memfault Beyond the Launch