avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] boot.h flash macros ignore spm - irq


From: Jörg Diederich
Subject: [avr-libc-dev] boot.h flash macros ignore spm - irq
Date: Sat, 23 Sep 2006 16:34:37 +0800

hello,
just subscribed to the list, first hello to everyone.

playin around with the boot.h macros. 
in my opinion they are not correct at all. they ignore the SPMIE bit, so 
writing isr's while using the macros will result in not-working-code.

for instance normal page erase:

        "movw r30, %2\n\t"                       \
        "sts %0, %1\n\t"                         \
        "spm\n\t"                                \
        :                                        \
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
          "r" ((uint16_t)address)                \
        : "r30", "r31"                           \

clears all SPM_REG bits except the bits for the action (BOOT_PAGE_ERASE in this 
case).

my suggestion is to accept three more cycles and saving SPM_REG first, using 
'lds' to temporary and 'or' the wished bit mask. if accepted, it should be easy 
to patch, i guess.
changed macro for normal page erase would look like this. just tryed it, seems 
to work.
    __asm__ __volatile__                         \
    (                                            \
        "movw r30, %A3\n\t"                      \
        "sts  %1, %C3\n\t"                       \
        "lds  __tmp_reg__, %0\n\t"               \
        "or __tmp_reg__, %2\n\t"                 \
        "sts %0, __tmp_reg__\n\t"                \
        "spm\n\t"                                \
        :                                        \
        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
          "r" ((uint8_t)((1<<PGERS)|(1<<SPMEN))), \
          "r" ((uint32_t)dest_addr)                \
        : "r30", "r31"                           \
    );                              

else someone please note the behaviour in the manual :) maybe it could save 
other people a lot of time looking for errors caused by this.

thanks for reading, would be nice to see your opinions
bye joerg

-- 
_______________________________________________
Get your free email from http://www.graffiti.net

Powered By Outblaze




reply via email to

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