Skip to main content
Visitor II
September 13, 2006
Question

double and XTI_IRQHandler

  • September 13, 2006
  • 19 replies
  • 2706 views
Posted on September 13, 2006 at 12:49

double and XTI_IRQHandler

    This topic has been closed for replies.

    19 replies

    ewittAuthor
    Visitor II
    September 8, 2006
    Posted on September 08, 2006 at 12:27

    Hello @all,

    i have got some strange problem with double variables.

    I am trying to use a double variable inside the XTI_IRQHandler.

    I try to initialize the double with the value 2.0.

    When printing the Value it shows 0.0000. (see attached jpg)

    The same thing works fine inside main()

    I have no clue whats happening there...

    Please help!

    regards,

    Erwin

    ________________

    Attachments :

    double.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtBv&d=%2Fa%2F0X0000000aK8%2FuJ_RLPxab4ijK99SNICEBe7OpB6w6VeLyA1vyNbi9EU&asPdf=false
    Visitor II
    September 8, 2006
    Posted on September 08, 2006 at 13:00

    Hello ewitt,

    Which compiler are you using?

    ewittAuthor
    Visitor II
    September 8, 2006
    Posted on September 08, 2006 at 13:06

    I am using RVDK 2.1 with armcc.

    To complete the confusion:

    As i implemented a second function using a double variable ''ape'' the variable in the first function began to work. But the new one (''ape'') began to behave the same as the first variable before!! (See 2nd jpg to know what i mean)

    The variable ''wasgeht'' only gets the right value if the variable ''ape'' in the new function is initialized AND USED!.

    I really wonder what is going on here...

    [ This message was edited by: ewitt on 08-09-2006 16:48 ]

    ________________

    Attachments :

    double2.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtDG&d=%2Fa%2F0X0000000aKL%2F5z8u7ECQiOfMrcRYPchtbC0rplADJdnH_onmxb4UdU4&asPdf=false
    Visitor II
    September 8, 2006
    Posted on September 08, 2006 at 13:30

    The following contains information relating to your particular compiler and fp support. Is it of any use?

    http://www.arm.com/support/faqdev/14116.html

    ewittAuthor
    Visitor II
    September 8, 2006
    Posted on September 08, 2006 at 14:56

    No, it did not help me. I don't know if i understood everything correct. But as far as i understood i checked everything.: The memory area at __user_libspace is not changing and setting the locale with setlocale(LC_ALL,''C''); does not help either.

    But i encountered the next strange thing happening in the IRQHandler-function (Again: all of the strange behaviour does not happen in main()!!!): asin() and other math.h functions returning double return bogus data instead of the calculated value.(see jpg)

    I really would like to know whats happaning here.

    I attached the project files, hopefully that helps...

    cheers,

    Erwin

    [ This message was edited by: ewitt on 08-09-2006 19:53 ]

    ________________

    Attachments :

    double3.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtDL&d=%2Fa%2F0X0000000aKM%2FYEYnkOLCdON40QZoaiP3wQbMyyC5jdkzF.tBVn8gI2M&asPdf=false

    p2dV01.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtDQ&d=%2Fa%2F0X0000000aKN%2FvHJLr0ey2L7AMa8M05M0TrmPsz8T9xxoVA8Q_QcwXb8&asPdf=false
    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 07:41

    erwin,

    The printf and sprintf are re-entrant. This could cause corruption if the interrupt fires while the printf or sprintf functions are being executed. How often do your interrupts happen?

    Personally I don't tend to use the printf and sprintf functions as they are quite large (the GPIO read and write functions aren't so bad).

    ewittAuthor
    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 08:19

    Not that often, at max. every 1.044 sec. [1/(16000000)*255*65535] a Interrupt is fired.

    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 08:44

    Have you any means other than the printf statements to check the values of these variables? Can you single step through the debugger or simulator to read the values that way?

    ewittAuthor
    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 09:09

    I checked the values with a if-statement (like if (ape>xy)). The double values are OK!, only the sprintf and printf outputs are incorrect... It seems to me like some kind of debugger problem. Because when i do a breakpoint at the interuptserviceroutine and try to examine the veriable ''ape'' or another double variable inside any ISR i get an Error like ''Unable to determine location''. --> The debugger cannot evaluate a double varibale inside any ISR!! But is there a connection between the sprintf problem?

    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 09:18

    What does the mapfile say about the location of these variables? Does declaring them as static or volatile make any difference? This should force the linker to keep them in the same memory location (although with such a small program it should anyway).

    Other than this the only problem I can see is the re-entrance problem from earlier. Do the external interrupts fire very often?