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 Interrupt Problem on atmel 89c51cc01

This program sends 1 byte sequential numbers to CAN BUS using Channel 12. Interrupt occurs each time message is transferred. When interrupt occurs CANCONCH and CANSTCH registers should be cleared for the next intterrupt.

Unfortunatelly clearing CANCONCH and CANSTCH doesnt clear the CANGIT register automatically althoug it should be (From Atmels data book). For this reason Interrupt function is called back for the second time.

The only solution i found is to clear CANGIT^7 manually Altough it is imposible to clear this bit in real IC (CANGIT^7 is readonly bit) but keil software does?
What do you suggest to overcome this problem. is this a bug or am i doing something wrong?

Thanks for all

#include <Can1_Drv.h>
#include <reg51cc01.h>
static bit SendInfo;
unsigned char i;

void CanInterrupt (void) interrupt 7 using 1
{
 SendInfo = 0; //Init for nex message to send
 CANCONCH = 0; //reset Launch Transmission
 CANSTCH = 0;  //reset TxOk
 //CANGIT = 0; 
}

void CanSend () {
 unsigned char num_data;

 CANMSG = i++;
 for (num_data = 1; num_data<8; num_data++)
  {
 	CANMSG = 0x00;
  }
 CANCONCH = 0x51; //Send 1 byte msg. id29
 SendInfo = 1;	//Message is being sent
}

void main (void)
{

 CanInit ();

 EA = 1; // Enable All Interrupts (IEN0^7)
 ECAN = 1; // Enable CAN Interrupts (IEN1^1)
 CANGIE	= 0x10;	// En. Transmit Int.CANGIE^4)
 CANIE1 = 0x10;	// Enable M.O. Int.(CANIE1^4)
 SendInfo = 0;	// Msg hasn't been sent yet

 CANPAGE = CanChannel(12);// Use Channel 12
 CANSTCH = 0x00;
 CanSetIDT(ID0);

 while (1)
 {
  if (!SendInfo) // Wait until message is send
      {
	CanSend ();
      }
 }

}

0