CAN ROM API compatibility between LPC11Cxx and LPC15xx

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

CAN ROM API compatibility between LPC11Cxx and LPC15xx

1,675 Views
ptpaterson
Contributor I

Is anyone maintaining a CAN library compatible with both LPC11Cxx and LPC15xx devices?  Do you have suggestions on how I might go about it?  I don't think it should be too difficult, but want to see what experience any others may have had.

 

I have a code base built up with LPC11Cxx using the LPCOpen chip library.  I need more functionality for a new device and want to use the LPC15xx series.  In general, I am a little confused why naming is so different between the LPCOpen chip libraries.  I am wondering if part of my porting the library should be to refactor some things in the LPC11Cxx chip library to be more in sync with the LPC15xx library.  But then, my concern is about maintaining a fork of the LPCOpen libraries and dealing with updates.

 

For the most obvious example:

LPC11Cxx:

void CAN_IRQHandler(void) {

      LPC_CCAN_API->isr();

}

LPC15xx:

void CAN_IRQHandler(void) {

  LPC_CAND_API->hwCAN_Isr(pCanHandle);

}

 

I am curious if CCAN and CAND are names that actually mean something to distinguish the two, or if they are arbitrary, as though the writers of the chip libraries didn't know the other existed...

 

The ROM APIs are definitely different, and the structures themselves (LPC_CCAN_API and LPC_CAND_API) reflect that.  The initialization must be unique between the devices - at a minimum, the LPC15xx ROM API calls require a handle to a CAN device in order to accommodate chips with multiple devices and allows you to define memory space (more than 255 canopen dictionary entries YAY!).  So, I need a compatibility layer of some sort anyway to maintain a single library for the two devices - more compatible naming would not prevent that.  But I am lamenting that I think it could have made it easier.

 

Thoughts?  Thank you.

Labels (4)
0 Kudos
4 Replies

1,003 Views
devan
Contributor I

Hi,

I know the LPC1549 support CAN2.0b part already, and I use CAN2.0a part protocol very well.

but I don't konw how to configure CAN2.0b protocol?

according to SAEJ1939 protocal parameters, PGN, ID,

example: PGN = 0X1234, ID=0X18001800;

how to write configure routine?

id= CAN_MSGOBJ_EXT | CAN_MSGOBJ_DATA|ID?

mask = PGN?

Thank you

0 Kudos

1,003 Views
soledad
NXP Employee
NXP Employee

Hi,

Please check the below threads, you will find examples that you can use as reference.

Working LPC15xx LQFP48 CAN Sample | www.LPCware.com 

LPC1549 and CAN 

Have a great day,
Sol

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

0 Kudos

1,003 Views
soledad
NXP Employee
NXP Employee

Hello Paul,

The startup code generated by the LPCXpresso LPC15xx new project wizard got out of sync with the code in the public release of the LPC15xx LPCOpen bundle - meaning that the names of some of the interrupt handler names referenced in the startup code produced for new projects do not match the names of the corresponding handlers used in the LPCOpen examples for LPC15xx.

This means that if projects are created with the wizard and you pull in interrupt handler code from the LPCOpen examples, then some handlers may never get executed (the default handlers in the startup code will get invoked instead).

Please check more information in the next thread:

Updated LPC15xx startup files for LPCOpen compatibility | www.LPCware.com

In addition you can find a CAN example at the next link:

Working LPC15xx LQFP48 CAN Sample | www.LPCware.com


Have a great day,
Sol

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

0 Kudos

1,003 Views
ptpaterson
Contributor I

Thank you for your response.

First, I have the latest LPCXpresso release (v8), and it appears that the changes in the link you provide are already incorporated.  At any rate, all of the interrupt handlers in my existing startup file and the one linked to are identical.  So these are not an issue.  But I appreciate your concern, and since that I didn't specify my IDE version, this could have been a real problem for me.

Second, my question is concerned with the difference between LPC11 and LPC15.  In my original post you can even see that the two IRQ handlers are the same from LPC11 to LPC15.  What is NOT the same are the pointers to the CAN peripherals, which are defined in their respective CAN ROM API files.  Are these files out of sync as well?

The differences in the libraries make it non-trivial to maintain code for controllers, and I am searching for any others experience in trying to do so.  What is most likely, is that it will be too cumbersome to maintain a portable version of our code and we will need to obsolete anything with a LPC11 and revise it all for LPC15.

0 Kudos