Sign in

username:

password:



Not a member?

Search c55x



Search tips

Subscribe to c55x



c55x by Keywords

AIC23 | C5509 | CCS | CSL | EMIF | EVM | GEL | GPIO | HPI | Interfacing | JTAG | McBSP | OMAP | Omap15 | OMAP59 | RTDX | SDRAM | TMS320VC5509 | USB | XDS5

Sponsor

NEW! TMS320C6474: 3x the performance. 1/3 the cost. Three 1 GHz cores on 1 chip.

Discussion Groups

Discussion Groups | TMS320C55x | RTC_localtime return data stored on stack

Technical discussions about the TI C55x DSPs (including the c5501, c5502, c5503, c5507, c5509, c5510 and OMAP5910).

  

Post a new Thread

RTC_localtime return data stored on stack - kd7lmo - Aug 21 13:56:47 2007



I'm using the RTC_localtime function in the following code snippet. 
If I get an interrupt between the time I call the function and save
the values, the tm structure is corrupt.  In looking at the assembly
code, the TI library call is storing the return of the RTC_localtime
on the stack instead of a static structure.  According to the C
reference manual, the localtime functions generally allocate static
memory.

How can I force the RTC_localtime method to use a static allocation
rather than the stack?

Any other work around ideas?

Yes, I could disable the interrupts, but it takes around 500uS for the
function to run and I don't want to disable them for that long.

Thanks
    struct tm *tmTime = RTC_localtime(&time);
    
>> Interrupt occurs here.

    // Save the time values.
    rtcTime->second = tmTime->tm_sec;
    rtcTime->minute = tmTime->tm_min;
    rtcTime->hour   = tmTime->tm_hour;



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: RTC_localtime return data stored on stack - kd7lmo - Aug 23 7:49:44 2007

Just wanted to answer my own question after I asked TI support.  Here
was their response:

TI said, "Yes, This is a bug defect reported recently regarding CSL
2.31. The bug # is PSG00003124

v2.31.00.9 The function RTC_localtime() returns a local structure that
is allocated on the stack.  This is not correct because the content of
the stack may be modified when an interrupt occurs  RTC_localtime() :
struct tm local; : return &local;

The work around is to allocate the structure outside the function and
globally."

They also sent the CSL source code, so you could ask for that and
compile your own RTC_localtime as a work around.
--- In c...@yahoogroups.com, "kd7lmo" <mgray@...> wrote:
>
> I'm using the RTC_localtime function in the following code snippet. 
> If I get an interrupt between the time I call the function and save
> the values, the tm structure is corrupt.  In looking at the assembly
> code, the TI library call is storing the return of the RTC_localtime
> on the stack instead of a static structure.  According to the C
> reference manual, the localtime functions generally allocate static
> memory.
> 
> How can I force the RTC_localtime method to use a static allocation
> rather than the stack?
> 
> Any other work around ideas?
> 
> Yes, I could disable the interrupts, but it takes around 500uS for the
> function to run and I don't want to disable them for that long.
> 
> Thanks
>     struct tm *tmTime = RTC_localtime(&time);
>     
> >> Interrupt occurs here.
> 
>     // Save the time values.
>     rtcTime->second = tmTime->tm_sec;
>     rtcTime->minute = tmTime->tm_min;
>     rtcTime->hour   = tmTime->tm_hour;
>



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Re: RTC_localtime return data stored on stack - Jeff Brower - Aug 23 10:25:19 2007

M Gray-

> Just wanted to answer my own question after I asked TI support.  Here
> was their response:
> 
> TI said, "Yes, This is a bug defect reported recently regarding CSL
> 2.31. The bug # is PSG00003124
> 
> v2.31.00.9 The function RTC_localtime() returns a local structure that
> is allocated on the stack.  This is not correct because the content of
> the stack may be modified when an interrupt occurs  RTC_localtime() :
> struct tm local; : return &local;
> 
> The work around is to allocate the structure outside the function and
> globally."
> 
> They also sent the CSL source code, so you could ask for that and
> compile your own RTC_localtime as a work around.

Thanks for pointing out this CSL bug!  What version of CCS do you have?  I'm
wondering what is the latest version of C55x CSL.

-Jeff

> --- In c...@yahoogroups.com, "kd7lmo" <mgray@...> wrote:
> >
> > I'm using the RTC_localtime function in the following code snippet.
> > If I get an interrupt between the time I call the function and save
> > the values, the tm structure is corrupt.  In looking at the assembly
> > code, the TI library call is storing the return of the RTC_localtime
> > on the stack instead of a static structure.  According to the C
> > reference manual, the localtime functions generally allocate static
> > memory.
> >
> > How can I force the RTC_localtime method to use a static allocation
> > rather than the stack?
> >
> > Any other work around ideas?
> >
> > Yes, I could disable the interrupts, but it takes around 500uS for the
> > function to run and I don't want to disable them for that long.
> >
> > Thanks
> >
> >
> >     struct tm *tmTime = RTC_localtime(&time);
> >
> > >> Interrupt occurs here.
> >
> >     // Save the time values.
> >     rtcTime->second = tmTime->tm_sec;
> >     rtcTime->minute = tmTime->tm_min;
> >     rtcTime->hour   = tmTime->tm_hour;



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Re: RTC_localtime return data stored on stack - Sima Baymani - Aug 23 12:49:55 2007

Regarding latest C55x CSL:
Not sure if this helps, but I found this, which I've used.
http://focus.ti.com/docs/toolsw/folders/print/sprc133.html
-Sima

On 8/23/07, Jeff Brower <j...@signalogic.com> wrote:
>
> M Gray-
>
> > Just wanted to answer my own question after I asked TI support. Here
> > was their response:
> >
> > TI said, "Yes, This is a bug defect reported recently regarding CSL
> > 2.31. The bug # is PSG00003124
> >
> > v2.31.00.9 The function RTC_localtime() returns a local structure that
> > is allocated on the stack. This is not correct because the content of
> > the stack may be modified when an interrupt occurs RTC_localtime() :
> > struct tm local; : return &local;
> >
> > The work around is to allocate the structure outside the function and
> > globally."
> >
> > They also sent the CSL source code, so you could ask for that and
> > compile your own RTC_localtime as a work around.
>
> Thanks for pointing out this CSL bug! What version of CCS do you have? I'm
> wondering what is the latest version of C55x CSL.
>
> -Jeff
>
> > --- In c...@yahoogroups.com <c55x%40yahoogroups.com>, "kd7lmo"
> <mgray@...> wrote:
> > >
> > > I'm using the RTC_localtime function in the following code snippet.
> > > If I get an interrupt between the time I call the function and save
> > > the values, the tm structure is corrupt. In looking at the assembly
> > > code, the TI library call is storing the return of the RTC_localtime
> > > on the stack instead of a static structure. According to the C
> > > reference manual, the localtime functions generally allocate static
> > > memory.
> > >
> > > How can I force the RTC_localtime method to use a static allocation
> > > rather than the stack?
> > >
> > > Any other work around ideas?
> > >
> > > Yes, I could disable the interrupts, but it takes around 500uS for the
> > > function to run and I don't want to disable them for that long.
> > >
> > > Thanks
> > >
> > >
> > > struct tm *tmTime = RTC_localtime(&time);
> > >
> > > >> Interrupt occurs here.
> > >
> > > // Save the time values.
> > > rtcTime->second = tmTime->tm_sec;
> > > rtcTime->minute = tmTime->tm_min;
> > > rtcTime->hour = tmTime->tm_hour;

-- 
                                           -Sima



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Re: RTC_localtime return data stored on stack - Jeff Brower - Aug 24 11:54:37 2007

M Gray-

> It is the latest 3.3 CCS with Service Release 5 and code generator 3.3.5.

Ok.  I don't think we have a 3.3 install in our lab yet.  I will make sure the next CCS seats
we get are 3.3.

> Avoid the 3.3.6 code generator.  It won't compile C++ code.

And the 3.3.5 generator does compile C++ code?  That's odd.

> Overall though, the 3.3 TI stuff is pretty good.

Yes most of the time, at least more so than other DSP vendors I've been associated with.

-Jeff

> On Thu, 23 Aug 2007, Jeff Brower wrote:
>
>> M Gray-
>>
>> > Just wanted to answer my own question after I asked TI support.  Here
>> > was their response:
>> >
>> > TI said, "Yes, This is a bug defect reported recently regarding CSL
>> > 2.31. The bug # is PSG00003124
>> >
>> > v2.31.00.9 The function RTC_localtime() returns a local structure that
>> > is allocated on the stack.  This is not correct because the content of
>> > the stack may be modified when an interrupt occurs  RTC_localtime() :
>> > struct tm local; : return &local;
>> >
>> > The work around is to allocate the structure outside the function and
>> > globally."
>> >
>> > They also sent the CSL source code, so you could ask for that and
>> > compile your own RTC_localtime as a work around.
>>
>> Thanks for pointing out this CSL bug!  What version of CCS do you have?  I'm
>> wondering what is the latest version of C55x CSL.
>>
>> -Jeff
>>
>> > --- In c...@yahoogroups.com, "kd7lmo" <mgray@...> wrote:
>> > >
>> > > I'm using the RTC_localtime function in the following code snippet.
>> > > If I get an interrupt between the time I call the function and save
>> > > the values, the tm structure is corrupt.  In looking at the assembly
>> > > code, the TI library call is storing the return of the RTC_localtime
>> > > on the stack instead of a static structure.  According to the C
>> > > reference manual, the localtime functions generally allocate static
>> > > memory.
>> > >
>> > > How can I force the RTC_localtime method to use a static allocation
>> > > rather than the stack?
>> > >
>> > > Any other work around ideas?
>> > >
>> > > Yes, I could disable the interrupts, but it takes around 500uS for the
>> > > function to run and I don't want to disable them for that long.
>> > >
>> > > Thanks
>> > >
>> > >
>> > >     struct tm *tmTime = RTC_localtime(&time);
>> > >
>> > > >> Interrupt occurs here.
>> > >
>> > >     // Save the time values.
>> > >     rtcTime->second = tmTime->tm_sec;
>> > >     rtcTime->minute = tmTime->tm_min;
>> > >     rtcTime->hour   = tmTime->tm_hour;
>>



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )

Re: Re: RTC_localtime return data stored on stack - mgra...@ess-us.com - Aug 24 16:06:17 2007

It is the latest 3.3 CCS with Service Release 5 and code generator 3.3.5.  
Avoid the 3.3.6 code generator.  It won't compile C++ code.

Overall though, the 3.3 TI stuff is pretty good.

On Thu, 23 Aug 2007, Jeff Brower wrote:

> M Gray-
> 
> > Just wanted to answer my own question after I asked TI support.  Here
> > was their response:
> > 
> > TI said, "Yes, This is a bug defect reported recently regarding CSL
> > 2.31. The bug # is PSG00003124
> > 
> > v2.31.00.9 The function RTC_localtime() returns a local structure that
> > is allocated on the stack.  This is not correct because the content of
> > the stack may be modified when an interrupt occurs  RTC_localtime() :
> > struct tm local; : return &local;
> > 
> > The work around is to allocate the structure outside the function and
> > globally."
> > 
> > They also sent the CSL source code, so you could ask for that and
> > compile your own RTC_localtime as a work around.
> 
> Thanks for pointing out this CSL bug!  What version of CCS do you have?  I'm
> wondering what is the latest version of C55x CSL.
> 
> -Jeff
> 
> > --- In c...@yahoogroups.com, "kd7lmo" <mgray@...> wrote:
> > >
> > > I'm using the RTC_localtime function in the following code snippet.
> > > If I get an interrupt between the time I call the function and save
> > > the values, the tm structure is corrupt.  In looking at the assembly
> > > code, the TI library call is storing the return of the RTC_localtime
> > > on the stack instead of a static structure.  According to the C
> > > reference manual, the localtime functions generally allocate static
> > > memory.
> > >
> > > How can I force the RTC_localtime method to use a static allocation
> > > rather than the stack?
> > >
> > > Any other work around ideas?
> > >
> > > Yes, I could disable the interrupts, but it takes around 500uS for the
> > > function to run and I don't want to disable them for that long.
> > >
> > > Thanks
> > >
> > >
> > >     struct tm *tmTime = RTC_localtime(&time);
> > >
> > > >> Interrupt occurs here.
> > >
> > >     // Save the time values.
> > >     rtcTime->second = tmTime->tm_sec;
> > >     rtcTime->minute = tmTime->tm_min;
> > >     rtcTime->hour   = tmTime->tm_hour;
>



(You need to be a member of c55x -- send a blank email to c55x-subscribe@yahoogroups.com )