EmbeddedRelated.com
Forums

using functions to control and read RTC on F5438A chip?

Started by one00100100 March 18, 2013
Hey Folks,

I have a project that began on the F5438 (non-A) chip. I have migrated it to the A version because we were afraid that the non a

version would not be available as TI "does not recomend it for new projects". TI claims they have fixed the RTC in the "A" version,

so I was trying to implement the RTC Workaround described in slac166r document. It contains the files: "RTC.h", RTC_Sample",

"RTC_Workaround.ewd", "RTC_Workaround.ewp", "RTC_Workaround (IAR IDE Workspace)", and "RTCASMFunctions_IAR (S43 File)".

I am using the IAR full workbench, but cannot figure our which of these files to add to my project to gain access to the functions,

"SetRtcYear", GetRtcYear", etc. I have always coded in c or c++ with IAR. I did some assembler-only coding back in the 1970's with a

dos-bases assembler. I have not mixed assembler and c using IAR and the MSP430 chips. I notice that the function names in the file

"RTCASMFunctions_IAR" appear to be in C format, while the function bodies appear to be assembler format.

The instructions on mixing c and assembler in the IAR book is as clear as mud to me. Would someone be so kind as to show me how to

incorporate this workaround into my current c, c++ project?

Beginning Microcontrollers with the MSP430

On 2013-03-18 16:50, one00100100 wrote:
> Hey Folks,
>
> I have a project that began on the F5438 (non-A) chip. I have migrated
> it to the A version because we were afraid that the non a
>
> version would not be available as TI "does not recomend it for new
> projects". TI claims they have fixed the RTC in the "A" version,
>
> so I was trying to implement the RTC Workaround described in slac166r
> document. It contains the files: "RTC.h", RTC_Sample",
>
> "RTC_Workaround.ewd", "RTC_Workaround.ewp", "RTC_Workaround (IAR IDE
> Workspace)", and "RTCASMFunctions_IAR (S43 File)".
>
> I am using the IAR full workbench, but cannot figure our which of these
> files to add to my project to gain access to the functions,
>
> "SetRtcYear", GetRtcYear", etc. I have always coded in c or c++ with
> IAR. I did some assembler-only coding back in the 1970's with a
>
> dos-bases assembler. I have not mixed assembler and c using IAR and the
> MSP430 chips. I notice that the function names in the file
>
> "RTCASMFunctions_IAR" appear to be in C format, while the function
> bodies appear to be assembler format.
>
> The instructions on mixing c and assembler in the IAR book is as clear
> as mud to me. Would someone be so kind as to show me how to
>
> incorporate this workaround into my current c, c++ project?
Hi!

Without any real knowledge about the example in question, you should be
able to mix C/C++ and assembler as follows:

Simply add the xxx.s43 and xxx.c files to your project. ".s43" is the
extension used for assembler source files.

In the IAR tools, a C function is represented as an assembler function
with an external label with the same name as the C function. (No leading
underscore, or name mangling.) Hence, in order to use it from C, all you
have to do is declare it with suitable parameters and return types
(which I assume is done in the header file).

On the other hand, if you are calling the function from C++, you must
inform the compiler that you are calling a C function. You do this by
writing:

extern "C"
{
// Declarations goes here, for example:
void my_func(void);
}

Declarations like this might already be included in the header files. If
not, it might be possible to write:

extern "C"
{
#include "RTC.h"
}

If you have concrete suggestions on how to make the description in books
less muddy, I'd be glad to forward them!

-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.
God bless you, Anders Lindgren!!
You've saved my butt again. Your advice was right to the point. You showed me which files to use, and the advice about making the functions usable under C++ was key. Thank you very, very much!

I would love to help clear up some of the documentation mud, but I'm so busy I have trouble finding time to go to the restroom. It is unfortunate that by the time our corporate attention turns to documentation, all the money has already been spent. This results in the task falling to a few, usually underpaid individuals who probably do the best they can.

My goal is to produce enough to keep my job for 5-8 more years if my health holds up so I can have a place to live in near poverty until I go to the old-folks home. Really not whining, just making the best of my current situation. Thank you for helping me toward that goal.

Thanks again,
Mike Raines

--- In m..., Anders Lindgren wrote:
>
> On 2013-03-18 16:50, one00100100 wrote:
> > Hey Folks,
> >
> > I have a project that began on the F5438 (non-A) chip. I have migrated
> > it to the A version because we were afraid that the non a
> >
> > version would not be available as TI "does not recomend it for new
> > projects". TI claims they have fixed the RTC in the "A" version,
> >
> > so I was trying to implement the RTC Workaround described in slac166r
> > document. It contains the files: "RTC.h", RTC_Sample",
> >
> > "RTC_Workaround.ewd", "RTC_Workaround.ewp", "RTC_Workaround (IAR IDE
> > Workspace)", and "RTCASMFunctions_IAR (S43 File)".
> >
> > I am using the IAR full workbench, but cannot figure our which of these
> > files to add to my project to gain access to the functions,
> >
> > "SetRtcYear", GetRtcYear", etc. I have always coded in c or c++ with
> > IAR. I did some assembler-only coding back in the 1970's with a
> >
> > dos-bases assembler. I have not mixed assembler and c using IAR and the
> > MSP430 chips. I notice that the function names in the file
> >
> > "RTCASMFunctions_IAR" appear to be in C format, while the function
> > bodies appear to be assembler format.
> >
> > The instructions on mixing c and assembler in the IAR book is as clear
> > as mud to me. Would someone be so kind as to show me how to
> >
> > incorporate this workaround into my current c, c++ project?
> Hi!
>
> Without any real knowledge about the example in question, you should be
> able to mix C/C++ and assembler as follows:
>
> Simply add the xxx.s43 and xxx.c files to your project. ".s43" is the
> extension used for assembler source files.
>
> In the IAR tools, a C function is represented as an assembler function
> with an external label with the same name as the C function. (No leading
> underscore, or name mangling.) Hence, in order to use it from C, all you
> have to do is declare it with suitable parameters and return types
> (which I assume is done in the header file).
>
> On the other hand, if you are calling the function from C++, you must
> inform the compiler that you are calling a C function. You do this by
> writing:
>
> extern "C"
> {
> // Declarations goes here, for example:
> void my_func(void);
> }
>
> Declarations like this might already be included in the header files. If
> not, it might be possible to write:
>
> extern "C"
> {
> #include "RTC.h"
> }
>
> If you have concrete suggestions on how to make the description in books
> less muddy, I'd be glad to forward them!
>
> -- Anders Lindgren, IAR Systems
> --
> Disclaimer: Opinions expressed in this posting are strictly my own and
> not necessarily those of my employer.
>