How to transfer variables between main.c and Event.c

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to transfer variables between main.c and Event.c

ソリューションへジャンプ
1,267件の閲覧回数
aaronlee
Contributor V

Hi,

We are using S12ZVCA with processor expert. How to transfer variables between main.c and Event.c?

main.c as follow:

unsigned int i;

void main(void)
{

   .........

   for(;;)
   {
      SCI_Send(i);
   }
   .........

........
/*
** ###################################################################
**
** This file was created by Processor Expert 10.3 [05.09]
** for the Freescale HCS12Z series of microcontrollers.
**
** ###################################################################
*/

Event.c as follow:

unsigned int i;

void TI1_OnInterrupt(void)
{
   ++i;                                       // How to transfer i to main.c
}

Best regards,

Aaron

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,096件の閲覧回数
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Aaron,

Create a global variable in your own source file can be the solution as you can see on the below link: 

https://community.nxp.com/message/24869?commentID=24869#comment-24869 

There is a description with different Code Warrior and MCU, but the principle is the same.

I hope it helps you.

Best regards,

Diana

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,097件の閲覧回数
dianabatrlova
NXP TechSupport
NXP TechSupport

Hi Aaron,

Create a global variable in your own source file can be the solution as you can see on the below link: 

https://community.nxp.com/message/24869?commentID=24869#comment-24869 

There is a description with different Code Warrior and MCU, but the principle is the same.

I hope it helps you.

Best regards,

Diana

0 件の賞賛
返信
1,096件の閲覧回数
aaronlee
Contributor V

Hi Diana,

Thanks for you quick reply. We got the link error as follow:

pastedImage_1.png

myfunc.c

#include "myfunc.h"

unsigned char TI1_CountUp;

unsigned char foo(void)
{
   return TI1_CountUp;
}

myfunc.h

#ifndef MYFUNC_H_
#define MYFUNC_H_

extern unsigned char TI1_CountUp;

unsigned char foo(void);

#endif /* MYFUNC_H_ */

Event.c

#include "Cpu.h"
#include "Events.h"

/* User includes (#include below this line is not maintained by Processor Expert) */
#include "Board_B0005_v100.h"
#include "myfunc.h"

............

void TI1_OnInterrupt(void)
{
   /* Write your code here ... */
   ++TI1_CountUp;
}

............

main.c

/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"

.........

/* User includes (#include below this line is not maintained by Processor Expert) */
#include "myfunc.h"

.........

void main(void)
{

   ........

   /* Write your code here */

   for(;;)

   {

      do{} while(!AS1_GetTxComplete());

      AS1_SendChar(TI1_CountUp);

   }

}

How to resolve the issue:

ERROR L1822: Symbol __copy in file C:/....../FLASH/Sources\main_c.obj is undefined

Best regards,

Aaron

0 件の賞賛
返信