lpcware

CAN Bus Receive Interrupt problem

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Richa on Fri Jun 19 23:27:15 MST 2015
Dear LPC community,

I am using LPC1756 microcontroller with the transceiver,SN65HVD233-HT. J1939 transmitter is integrated with LPC1756 via transceiver. The baurd rate is 250kbs.

Iam always getting bus error interrupt while receiving the data from the transmitter.Not able to receive the error free data frame.
The CAN2ICR registor value after enabling all interrupt is 0x790180 and receive error counter value is 81.

Initialization function that used for receiving a CAn data is mentioned below.
void can_Init()
{

    LPC_SC->PCONP       |=  (1 << 14);           /* Enable power to CAN2 block */
    LPC_PINCON->PINSEL4 |=  (0 << 15)|(1 << 14);           /*  RD2 (CAN2) */
    LPC_PINCON->PINSEL4 |=  (1 << 16);           /*  TD2 (CAN2) */
   
   NVIC_EnableIRQ(CAN_IRQn);                    /* Enable CAN interrupt */
   
  LPC_CANAF->AFMR = 2;                           /* By default filter is not used */
  
  LPC_CAN2->MOD   = 1;                               /* Enter reset mode */
  LPC_CAN2->IER   = 0;                               /* Disable all interrupts */
  LPC_CAN2->GSR   = 0;                               /* Clear status register */
       
    /* Set bit timing */

    CAN_cfgBaudrate(250000); 
    LPC_CAN2->IER   = 0x3FF;

   LPC_CAN2->MOD   = 0;        /* Enter normal operating mode */
  
}
static void CAN_cfgBaudrate (uint32_t baudrate) 
{
 
  uint32_t result = 0;
  uint32_t nominal_time;

  /* Determine which nominal time to use for PCLK */
  #define  PCLK            (100000000UL/4)
  if (((PCLK / 1000000) % 6) == 0) {
    nominal_time = 12;                   /* PCLK based on  72MHz CCLK */
  } else {
    nominal_time = 10;                   /* PCLK based on 100MHz CCLK */
  }

  /* Prepare value appropriate for bit time register */
  result  = (PCLK / nominal_time) / baudrate - 1;
  result &= 0x000003FF;
  result |= CAN_BIT_TIME[nominal_time];   //Bit Time code i have taken from c:/keil/arm/boards/keil/mcb1700/can

  LPC_CAN2->BTR  = result;                           /* Set bit timing */

}

Is anyone know How to clear the Buserror for receiving the all the IDs from the simulator.Please help me to solve this issue.
Thanks in Advance.

Outcomes