[Top][All Lists]

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

[avr-libc-dev] [bug #25062] sprintf_P and family problem on ATXMega128a1

From: Sebastian Schocke
Subject: [avr-libc-dev] [bug #25062] sprintf_P and family problem on ATXMega128a1
Date: Wed, 10 Dec 2008 13:22:34 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Gecko/2008102920 Firefox/3.0.4 (.NET CLR 3.5.30729)


                 Summary: sprintf_P and family problem on ATXMega128a1
                 Project: AVR C Runtime Library
            Submitted by: sschocke
            Submitted on: Wed 10 Dec 2008 01:22:32 PM GMT
                Category: Library
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: libc code
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.6.4
           Fixed Release: None



After tracing the program flow through the simulator on AVR Studio, I have
found that if I call sprintf_P, or any of the printf or scanf functions, the
Stack Pointer(SP) on the ATXMega128a1 is changed to a constant value. This
value is constant no matter what my previous SP value was, and changes to the
following value: 0x3FD8

This causes the AVR to reset whenever a return is issued from a function, as
the return jump address is stored on the stack.

Attached is a test case. The DEFINE BROKEN in the test_spf.c works as
follows. If set to 0, the code executes as expected, because the main()
function is never returned from, but sprintf_P still modifies the SP. If
BROKEN is set to 1, sprintf_P is called from inside the sayHello() function,
and the AVR resets when the end of the sayHello() function is reached.

Also, I tested the same code on an ATMega8, and everything there works fine.
Tracing it through a simulator on the ATMega8, the SP remains the same before
and after the call to sprintf_P.

Also, during simulating, it seems that the actual value that SP should be is
stored in the Y Pointer, so it seems like the SP value is not restored from
where it was saved when the sprintf_P call on an ATXMega completes. Perhaps
writing to SP is not allowed on the ATXMega.


File Attachments:

Date: Wed 10 Dec 2008 01:22:32 PM GMT  Name: test_spf.zip  Size: 2kB   By:
Test Case source code


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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