avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Re: avr-gcc-list Digest, Vol 11, Issue 19


From: Ewout Boks
Subject: [avr-gcc-list] Re: avr-gcc-list Digest, Vol 11, Issue 19
Date: Mon, 22 Dec 2003 11:07:37 +0100
User-agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031109


------------------------------

Date: Sat, 20 Dec 2003 22:52:06 +0000
From: Tom Maughan <address@hidden>
To: address@hidden
Subject: [avr-gcc-list] SPM Problem
Message-ID: <address@hidden>
Content-Type: text/plain; charset="us-ascii"; format=flowed
MIME-Version: 1.0
Precedence: list
Message: 2

I've got an odd problem. I'm porting some code from IAR to GCC and have hit a brick wall.

All the C works BUT we have some assembler to reprogram the internal flash. With the IAR it works just fine, with the GCC it hangs the moment it executes the SPM instruction after loading the SPMCR with 0x03 (erase).

The code is the same, its locating it in the correct place (1F800), its calling it correcly, its just not working.

We have alot of other assembly routines that work correctly.

I've replaced the IAR 'DW' with '.word' but I have not changed the parameter register numbers. The programming sequence is entirely assembly and is called by void program_flash(void) and then each assembler function sets the correct registers before calling the next so I cannot see how changing from R18 etc.. to R24 etc.. would make a difference.

Anyone else had issues with SPM?


I reckon from your description that you are porting the DES bootloader (app note AVR230) or something similar.

When calling the programming routine in this app note, the API is:

extern void spmWriteWord(prog_char *addr, unsigned int data);

for writing a 16 bit word to the page buffer (16 bit address). This is an assembly function provided by Atmel. Since arguments are passed, it is necessary to alter the calling arguments from R18 to R24 etc as you say yourself. In my case it seems to work correctly.

Are you certain that:

- you have instructed the linker to set this code at the bootloader address? Instructing spm from application code space is not guaranteed to work.

- indeed all registers are set up correctly? In the AVR230 code, the status register is saved and then restored after executing spm.

- the rampz bit is set properly when using > 64 KByte addressing ?

This is my code for the above function:

//=============================================================================
// Writes one word to a temporary page buffer

/*   tot 64K byte geheugen (ATMega32, ATMega64):  */
/* IAR : r16,r17 adres --> GCC : r24,r25 adres */
/* IAR : r18,r19 data  --> GCC : r22,r23 data  */

/*   meer dan 64K byte geheugen, RAMPZ gezet (ATMega128):  */
/* IAR : r16,r17,r18 adres  --> GCC : r22,r23,r24 adres */
/* IAR : r20,r21 data       --> GCC : r20,r21 data  */

spmWriteWord:
        #ifdef __RAMPZ__
/* ATMega 128 */
/* IAR */
/*              movw    r1:r0, r21:r20 */
/* GCC */
                movw    r0, r20
        #else
/* ATMega 32 en anderen */
/* IAR */
/*              movw    r1:r0, r19:r18 */
/* GCC */
                movw    r0, r22
        #endif
        ldi             r22, 1
rjmp spmSPM ; calls main spm routine. expects address in r24, r25 or r22,r23 and rampz in r25


Good luck !









Many thanks!

--

  _______
|_     _|-----.--------.   tom[at]tmaughan[.]co[.]uk
   |   |    _  |        |   tpm195[at]zepler[.]net
   |___|  _____|__|__|__|   http://www.tmaughan.co.uk


------------------------------

_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list


End of avr-gcc-list Digest, Vol 11, Issue 19
********************************************





reply via email to

[Prev in Thread] Current Thread [Next in Thread]