AnsweredAssumed Answered

MC9S12XHY CanBus Id and Acceptance problem

Question asked by Hüseyin Yüce Kürüm on Feb 20, 2014
Latest reply on Feb 25, 2014 by lama

!

Hi,

My canbus module send data fine but does not accept the incomming messages and im out of ideas. A push in the right direction will be greatly appreciated.

 

1.

CAN0IDAC_IDAM = 0x00U;               /* Set the acceptance mode  2x32bit */

 

  CAN0IDAR0 = 0x00U;                  

  CAN0IDAR1 = 0x00U;                 

  CAN0IDAR2 = 0x00U;                 

  CAN0IDAR3 = 0x80U;

with mask0-3 0x00 im sending my messages to 0x80.

 

2. same id with mask0-2 0xFF and mask3 0x00. im sending my messages to 0x80.

3. same id with mask0-3 0xFF.  in theory it should accept everything at this point. im sending my messages to 0x80.


4.im setting the SRR and IDE bits in to the id

  CAN0IDAR0 = 0x00U;                  

  CAN0IDAR1 = 0x18U;                 

  CAN0IDAR2 = 0x00U;                 

  CAN0IDAR3 = 0x10U;

mask0-3= 0x0

now im sending to the ids;

- 0x10

-0x8

-0x180010

 

well im just trying random stuff now. i managed to get some data with

ID0-3= 0x0

mask0-2= 0x0 and mask3=0xFF  but it worked only for a couple of days and it is not acceptable for the actual project.

 

So im in need of help. What im i doing wrong?

 

Thanks.

Yuce

 


void CAN1_Init(void)

{

  /* CAN0CTL1: CANE=1,CLKSRC=0,LOOPB=0,LISTEN=0,BORM=0,WUPM=0,SLPAK=0,INITAK=0 */

  CAN0CTL1 = 0x80U;                    /* Set the control register */

  /* CAN0CTL0: RXFRM=0,RXACT=0,CSWAI=0,SYNCH=0,TIME=0,WUPE=0,SLPRQ=0,INITRQ=1 */

  CAN0CTL0 = 0x01U;                    /* Set the control register */

  CAN0IDAC_IDAM = 0x00U;               /* Set the acceptance mode */

  CAN0IDAR0 = 0x00U;                   /* Set the acceptance code, register CAN0IDAR0 */

  CAN0IDAR1 = 0x18U;                   /* Set the acceptance code, register CAN0IDAR1 */

  CAN0IDAR2 = 0x00U;                   /* Set the acceptance code, register CAN0IDAR2 */

  CAN0IDAR3 = 0x10U;                   /* Set the acceptance code, register CAN0IDAR3 */

  CAN0IDAR4 = 0x00U;                   /* Set the acceptance code, register CAN0IDAR4 */

  CAN0IDAR5 = 0x00U;                   /* Set the acceptance code, register CAN0IDAR5 */

  CAN0IDAR6 = 0x00U;                   /* Set the acceptance code, register CAN0IDAR6 */

  CAN0IDAR7 = 0x00U;                   /* Set the acceptance code, register CAN0IDAR7 */

  CAN0IDMR0 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR0 */

  CAN0IDMR1 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR1 */

  CAN0IDMR2 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR2 */

  CAN0IDMR3 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR3 */

  CAN0IDMR4 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR4 */

  CAN0IDMR5 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR5 */

  CAN0IDMR6 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR6 */

  CAN0IDMR7 = 0x00U;                   /* Set the acceptance mask, register CAN0IDMR7 */

  /* CAN0BTR0: SJW1=0,SJW0=1,BRP5=0,BRP4=0,BRP3=0,BRP2=0,BRP1=0,BRP0=1 */

  CAN0BTR0 = 0x41U;                    /* Set the device timing register */

  /* CAN0BTR1: SAMP=0,TSEG22=1,TSEG21=1,TSEG20=1,TSEG13=0,TSEG12=1,TSEG11=1,TSEG10=0 */

  CAN0BTR1 = 0x76U;                    /* Set the device timing register */

  CAN0CTL1_CLKSRC = 0x00U;             /* Select the clock source from crystal */

  CAN0CTL0_INITRQ = 0x00U;             /* Start device */

  while(CAN0CTL1_INITAK) {}            /* Wait for enable */

  /* CAN0RFLG: WUPIF=1,CSCIF=1,RSTAT1=1,RSTAT0=1,TSTAT1=1,TSTAT0=1,OVRIF=1 */

  CAN0RFLG |= 0xFEU;                   /* Reset error flags */

  /* CAN0RIER: WUPIE=0,CSCIE=1,RSTATE1=1,RSTATE0=1,TSTATE1=1,TSTATE0=1,OVRIE=0,RXFIE=1 */

  CAN0RIER = 0x7DU;                    /* Enable interrupts */

}

Outcomes