Robby
2010-02-04 20:15:02 UTC
Hello,
Igor, I hope you are still around, I would really like to persue what we
were talking about in the previous thread. I know this seems like we are
going backwards here, but the trouble I am having has more to do on structure
than coding... and ofcourse my lack of experience in C ! :-)
I hope all this will lead up to what I am looking for. Sometimes I have a
hard time putting this stuff into words.
Okay, I like your proposition of the two functions. So let me start with
that. There is a first problem that I am running into. I did the two
functions. The first one called set_curr_sys_osc() and the second one called
get_curr_sys_osc(). Here is what I did so far, I will try to keep it short:
=============================test.h
#ifndef TEST_H
#define TEST_H
#define COMPUTE_SYS_OSC(extCrys, fpllidiv, fpllmul, fpllodiv) \
(((float)(extCrys/fpllidiv)*(float)(fpllmul/fpllodiv))*1000000)
extern static float the_sys_osc; //< store the SYS_CURR_OSC value here!
#endif // TEST_H //
=================================test.c
#include <stdio.h>
#include "test.h"
// In exactly one .c file.
static float the_sys_osc=0;
void set_curr_sys_osc(float extCrys, float fpllidiv, float fpllmul, float
fpllodiv)
{
the_sys_osc = COMPUTE_SYS_OSC(extCrys, fpllidiv, fpllmul, fpllodiv);
}
int get_curr_sys_osc()
{
return (int) the_sys_osc;
}
int main()
{
set_curr_sys_osc(8.0, 2.0, 21.0, 8.0);
// >>> SYSTEMConfig() is not one of my functions!
//SYSTEMConfig((int)get_curr_sys_osc(), SYS_CFG_ALL);
return 0;
}
=======================================
The above code generates the following error:
1>c:\_dts_programming\pic\_microchip_issues\simulated in
vc++\define_macros\define_macros\define_macros\test.h(13) : error C2159: more
than one storage class specified
It seems to point to the extern value I created. I did this extern variable
like all the others.... meaning:
- declaring it in the header file
- innitializing it in exactly one .c file
- using it in a function of test.c
Why the error?
Please get back!
Igor, I hope you are still around, I would really like to persue what we
were talking about in the previous thread. I know this seems like we are
going backwards here, but the trouble I am having has more to do on structure
than coding... and ofcourse my lack of experience in C ! :-)
I hope all this will lead up to what I am looking for. Sometimes I have a
hard time putting this stuff into words.
Okay, I like your proposition of the two functions. So let me start with
that. There is a first problem that I am running into. I did the two
functions. The first one called set_curr_sys_osc() and the second one called
get_curr_sys_osc(). Here is what I did so far, I will try to keep it short:
=============================test.h
#ifndef TEST_H
#define TEST_H
#define COMPUTE_SYS_OSC(extCrys, fpllidiv, fpllmul, fpllodiv) \
(((float)(extCrys/fpllidiv)*(float)(fpllmul/fpllodiv))*1000000)
extern static float the_sys_osc; //< store the SYS_CURR_OSC value here!
#endif // TEST_H //
=================================test.c
#include <stdio.h>
#include "test.h"
// In exactly one .c file.
static float the_sys_osc=0;
void set_curr_sys_osc(float extCrys, float fpllidiv, float fpllmul, float
fpllodiv)
{
the_sys_osc = COMPUTE_SYS_OSC(extCrys, fpllidiv, fpllmul, fpllodiv);
}
int get_curr_sys_osc()
{
return (int) the_sys_osc;
}
int main()
{
set_curr_sys_osc(8.0, 2.0, 21.0, 8.0);
// >>> SYSTEMConfig() is not one of my functions!
//SYSTEMConfig((int)get_curr_sys_osc(), SYS_CFG_ALL);
return 0;
}
=======================================
The above code generates the following error:
1>c:\_dts_programming\pic\_microchip_issues\simulated in
vc++\define_macros\define_macros\define_macros\test.h(13) : error C2159: more
than one storage class specified
It seems to point to the extern value I created. I did this extern variable
like all the others.... meaning:
- declaring it in the header file
- innitializing it in exactly one .c file
- using it in a function of test.c
Why the error?
Please get back!
--
Sincere regards
Roberto
Sincere regards
Roberto