Hello
I assume you are using ProcessorExpert to generate code. Am I right?
I would recommend you to keep your source files separated from Processor Expert generated ones. You can do that the following way:
- Create a new source file where you implement your function and define the necessary global
variables / constants.
For example you have a file called myfunc.c containing the following:
Code: unsigned char myCount; unsigned char foo(void) { /*Some code here*/ return myCount; } - Add the file to the project (selecting Project -> "Add <...> to Project".
- Create a header file containing declaration for the global variables/constants you need and
prototype for the function. For the above source file the include file will be called myfunc.h and will
look as follow:
Code:extern unsigned char myCount;unsigned char foo(void);
- In the source file containing the implementation of the main function as well as in the Events.c file add an
include from the new header file (myfunc.h in our example).
Code:#include "Cpu.h"#include "Events.h"#include "myfunc.h"<...>
Then in main or in the Events module you can just use the function or variable the usual way.
in the main function make sure you write your code between the marks:
/* Write your code here */
/* For example: for(;
{ } */
and
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
That should do it and keep some kind of structure in the application.
I hope this helps.
CrasyCat