This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can variable be accessed in interrupt service function?Simple question!

Problem:
I use timer interrup to send data to ASC.In timer interrupt function if do like this (eg. S0TBUF = 0xXX),it works.but if do like this (eg. S0TBUF = data2send),There's always 0xff in S0TBUF.My routine has three parts: main.c gt1.c asc.c,variable data2send is defined in gt1.c. So i doubt that data2send can not be accessed in GT1 TIMER3 service routine.

// gt1.c
#include "MAIN.H"
#include "intrins.h"


static unsigned char data2send = 0xfe;

void GT1_vInit(void)
{
  T3CON = 0x0006;
  T3    = 0x6768;  //  load timer 3 register

  T3IC = 0x005E;

  T2CON = 0x0000;
  T2    = 0x0000;  //  load timer 2 register

  T4CON = 0x0027;
  T4    = 0x6768;  //  load timer 4 register


  T3R = 1;         //   set timer 3 run bit 
}


void GT1_viIsrTmr3(void) interrupt T3INT
{
    data2send = _crol_(data2send,1);
	S0TBUF = data2send;

}

Parents Reply Children
No data