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 11, 2006
    Posted on September 11, 2006 at 09:26

    Defining them as static or volatile does not help either ... (I have already tested that).

    As i said before, the XTI do not fire very often. approx 1time/sec.

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

    Ah, sorry, I thought that was the timer.

    If the debugger is reporting it cannot find the location you may need to tell the linker to add debug information to the files. What does the map file say? You should be able to call up the contents of the memory location of your variable with this information and make sure it is correct (although it will be in IEEE 754 format).

    Alternatively you could write your own UART method to output the values you need although beware that interpreting IEEE 754 may take a couple of days!

    ewittAuthor
    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 10:52

    I already know that the content of the double variables are correct. I checked it with multiple if-Statements. - No need to check the memory directly. Nevertheless I have to use sprintf and printf repectivly. But I am going to check the linker options...

    ewittAuthor
    Visitor II
    September 11, 2006
    Posted on September 11, 2006 at 14:50

    By trying to make a workaround of the problem with sprintf and printf I noticed that also mathematical functions returning double (like floor, abs, asin, etc.) do not operate correctly when executed from a interruptserviceroutine. The returned double values are incorrect (bogus). Doing the mathematical functions from main do work... I do not get the problem ...

    Visitor II
    September 12, 2006
    Posted on September 12, 2006 at 09:54

    The only difference between the operating modes I can think of offhand is that during an interrupt the chip will be using the INT mode instead of USER or SYSTEM. I don't know what effect this will have on the std libraries.

    You have previously said that the XTI fires every sec or so. How often does the timer fire? Do the two interrupts fire at the same or nearly the same time?

    ewittAuthor
    Visitor II
    September 12, 2006
    Posted on September 12, 2006 at 10:41

    TIMER1 Fires approx 1time/sec. and enables a ADC sampling. The ADC sampling takes approx. 40µ, then XTI (after end of conversion) is fired.

    Visitor II
    September 12, 2006
    Posted on September 12, 2006 at 11:19

    Well, I have no idea of the cause, but you could put the chip into a low-power mode before enabling the timer to wake it. When the chip wakes, you could perform all the tasks in your code.

    Not exactly satisfactory though, is it?

    Visitor II
    September 12, 2006
    Posted on September 12, 2006 at 11:30

    Just a shot in the dark, but could it be a stack alignment issue? I think I heard somewhere that in order for double-precision floating point to work, some runtime libraries require stack alignment on 8-byte boundary to be activated.

    ewittAuthor
    Visitor II
    September 13, 2006
    Posted on September 13, 2006 at 12:49

    the problem also use to happen with float variables...

    In order to narrow down the problem i wrote 2 functions. :

    Code:

    <BR><BR><BR>void isinc(int number, char* buffer) <BR><BR><BR>{ <BR><BR><BR> float sin; <BR><BR><BR> sin=asin(((float) number)/10); <BR><BR><BR> ftoa(sin,4,buffer); //converts float to char* <BR><BR><BR>} <BR><BR><BR> <BR><BR><BR>void fsinc(float number, char* buffer) <BR><BR><BR>{ <BR><BR><BR> float sin; <BR><BR><BR> sin=asin(number); <BR><BR><BR> ftoa(sin,4,buffer); //converts float to char* <BR><BR><BR>} <BR><BR><BR>

    The only difference is that the first accept int and the second float values. If i call both functions from a ISR e.g.

    Code:

    <BR><BR><BR>void T0TIMI_IRQHandler(void) <BR><BR><BR>{ <BR><BR><BR> char cisin[8], cfsin[8]; <BR><BR><BR> isinc(3, cisin); <BR><BR><BR> fsinc(0.3, cfsin); <BR><BR><BR>} <BR><BR><BR>

    Now cfsin and cisin are supposed to have the same value right? But they don't isinc works fine and fsinc returns nothing.

    If i set an breakpoint into both functions then I can see the right values in function isinc(), but if the debugger steps into fsinc(), he is not able to trace any float variable.

    I do not get whats going wrong!

    [ This message was edited by: ewitt on 13-09-2006 16:44 ]

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

    [ This message was edited by: ewitt on 13-09-2006 16:49 ]

    ________________

    Attachments :

    floattrouble.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtA8&d=%2Fa%2F0X0000000aJl%2Fz2NBu8gf0IEhFVpgCQsUJ7Upze2Pvbd9V6DFE37hGRc&asPdf=false