patchAVR C Runtime Library - Patches: patch #8902, Xmega's PROTECTED_WRITE is...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #8902: Xmega's PROTECTED_WRITE is incorrect for IO registers whose address is more than one byte

Submitter:  Pitchumani <pitchumani>
Submitted:  Wed 03 Feb 2016 01:21:12 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  pitchumani Open/Closed:  Closed

Fri 05 Feb 2016 06:03:54 AM UTC, comment #4: 
Pitchumani <pitchumani>
Group Member
Thu 04 Feb 2016 10:14:13 PM UTC, comment #3: 

OK, I checked it (on something else), and think I understand it.

Please go ahead, and commit it.

Btw., this Web interface mangles patches.  Better post them
as attachments.

Joerg Wunsch <joerg_wunsch>
Group administrator
Thu 04 Feb 2016 09:38:02 AM UTC, comment #2: 

This patch _PROTECTED_WRITE macro. Below is the disassembly (after applying the patch) for test in comment #1.
00000000 <main>:
   0:   cf 93           push    r28
   2:   df 93           push    r29
   4:   cd b7           in      r28, 0x3d       ; 61
   6:   de b7           in      r29, 0x3e       ; 62

   8:   88 ed           ldi     r24, 0xD8       ; 216
   a:   97 e0           ldi     r25, 0x07       ; 7
   c:   84 bf           out     0x34, r24       ; 52
   e:   90 93 00 04     sts     0x0400, r25

  12:   00 00           nop
  14:   df 91           pop     r29
  16:   cf 91           pop     r28
  18:   08 95           ret

Pitchumani <pitchumani>
Group Member
Thu 04 Feb 2016 09:24:35 AM UTC, comment #1: 

Testcase: protected_write.c
1 #include <avr/io.h>
2 #include <avr/xmega.h>
3
4 void main ()
5 {
6   _PROTECTED_WRITE(RTC_CTRL, RTC_PRESCALER_gm);
7 }

Compiler output:
$ avr-gcc -mmcu=atxmega128b1 -c protected_write.c
In file included from /install/avr/include/avr/io.h:570:0,
                 from protected_write.c:1:
protected_write.c: In function 'main':
protected_write.c:6:3: error: impossible constraint in 'asm'
   _PROTECTED_WRITE(RTC_CTRL, RTC_PRESCALER_gm);
   ^

Pitchumani <pitchumani>
Group Member
Wed 03 Feb 2016 01:21:12 PM UTC, original submission:  

Index: avr-libc/include/avr/xmega.h
===================================================================
diff --git a/trunk/avr-libc/include/avr/xmega.h b/trunk/avr-libc/include/avr/xmega.h
--- a/trunk/avr-libc/include/avr/xmega.h        (revision 2498)
+++ b/trunk/avr-libc/include/avr/xmega.h        (working copy)
@@ -63,9 +63,9 @@
                       "sts %[ioreg], %[val]"                   \
                       :                                        \
                       : [ccp] "I" (_SFR_IO_ADDR(CCP)),         \
-                        [ccp_ioreg] "d" (CCP_IOREG_gc),        \
-                        [ioreg] "M" (_SFR_MEM_ADDR(reg)),      \
-                        [val] "r" (value))
+                        [ccp_ioreg] "d" ((uint8_t)CCP_IOREG_gc),       \
+                        [ioreg] "n" (_SFR_MEM_ADDR(reg)),      \
+                        [val] "r" ((uint8_t)value))
 #endif /* DOXYGEN */

 #endif /* _AVR_XMEGA_H */

Pitchumani <pitchumani>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #36249:  protected-write-xmega.patch added by pitchumani (867B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by pitchumani (Submitted the item)
  • -email is unavailable- added by pitchumani
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-05 pitchumani Attached File- Added protected-write-xmega.patch, #36249
        StatusReady For Test Done
        Open/ClosedOpen Closed
    2016-02-03 pitchumani Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code