LPC1769 CAN_IRQHandler bug

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1769 CAN_IRQHandler bug

763 Views
kuldeepkumar
Contributor II

Hi, everyone.

I've just started working on LPC1769 on an custom board and I am having problems getting the CAN BUS to work using the drivers.

After some research here I've read that the drivers has a lot of bugs, and the links I've found pointing to new drivers always redirect to home in LPCware.com.

I am using CAN2 in LPC1769

Pins :
      LPC_SC->PCONP |= 1<<14;  /* Enable CAN2 */
      LPC_PINCON->PINSEL4 &= ~0x0003C000;       /* CAN2 is p2.7 and p2.8 */
      LPC_PINCON->PINSEL4 |= 0x00014000;

I have enabled the Receive interrupt

 

 CANx->IER = 0x01; /* Enable receive interrupts */
  NVIC_EnableIRQ(CAN_IRQn);

I am able to transmit and receive data. But during reception the control is not entering into CAN_IRQ_Handler.

I could verify the received data through the Receive buffer registers.

Please help me to resolve this issue.

Thanks in advance.

Labels (1)
3 Replies

541 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kuldeep kumar,

    Please tell me what the CAN driver you are using?

   Do you tried the lpcopen code for lpc1769 which can be downloaded from this link:

LPCOpen Software for LPC17XX|NXP 

   You can test this code, and put the breakpoint in the CAN_IRQHandler.

  If you still have problem with the lpcopen code, please kindly let me know.

Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
----------------------------------------------------------------------------------------------------------------------

541 Views
kuldeepkumar
Contributor II

Hello Kerry,

   Thanks for your kind reply.

Sorry for the late response.

I got my code working. The issue was with the acceptance filtering in CAN2. 

The acceptance filter and the Mask were not set properly.  Even though the messages were received in the receive buffers, the received ID's were not matched with filter ID's. So the Receive Status(Bit 0 in GSR) bit in Status register was not set further Interrupt(Bit 0 in ICR) was not set. Hence the control was not entering into CAN IRQ Handler.

I used this piece of code for setting Acceptance filter and mask

void init_AF( void )

int32_t address = 4;

/*off mode*/

LPC_CANAF->AFMR = 0x00000001;

/* Set explicit standard Frame*/

LPC_CANAF->SFF_sa = address;/* word 1*/

/* CAN2 IDENT FORCE1*/

LPC_CANAF_RAM->mask[1]=(0X001 << 29) | (0X400 << 16)| (1<<27)|

(0X001 << 13)| (0X500 ) | (1<<11) ;

/* Only Frame ID 0x400 and 0x500 are received in MBED.*/

address+=4;/*add 4 bytes (1 long word) to point to none used word.*/

/* Set group standard Frame*/

LPC_CANAF->SFF_GRP_sa = address;

/* Set explicit extended Frame*/

LPC_CANAF->EFF_sa = address;

/* Set group extended Frame*/

LPC_CANAF->EFF_GRP_sa = address;

/* Set End of Table */

LPC_CANAF->ENDofTable = address;

/* All have ENDofTable address means are not used.*/

/*normal mode*/

LPC_CANAF->AFMR = 0x00000000;

return;

/* end Program */

I will also try the LPC open code available in link provided by you.

Thanks for your support.

Have a great day.

0 Kudos

541 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Kuldeep kumar,

    Thank you for your updated information.

    Yes, in CAN receive, the acceptance filter is very important, if you configure the filter, you need to send the the CAN ID which can be received.

   If you still have question about it, please kindly let me know.

   If your problem is solved, please help to mark the correct answer, just to close this case.

   Thank you and have a nice day!

Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
--------------------------------------------------------------------------------------------------------------------

0 Kudos