LPC1769 Can Driver

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

LPC1769 Can Driver

7,224 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ajay on Wed Mar 23 16:20:53 MST 2011
Has anyone been able to successfully get CAN to work on the LPCXpresso 1769?
0 Kudos
Reply
61 Replies

2,412 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rtos on Mon Apr 04 16:15:20 MST 2011

Quote: larryvc
ValueCAN3 is almost 3 times the price of the CANUSB, maybe PriceyCAN3 would be a better name.:)

Does it have features that make it that much better to be worth the extra money spent?

I'm looking for a good CAN tool as well and have to research this.



larryvc,

I have not used the http://www.canusb.com/ tool so I can not comment on its pros/cons. 

In general, things to look for are:
1) Maximum baud rate before it starts to miss messages?  The tools below are good to 1GHz.
2) Isolation
3) API to interface to your own custom programs (ie Visaul Basic, Visual C, etc.
4) Support
5) Mechanical quality.

I have used the following tools and here are my opinions. 
1) Vector CANalyzer software with Vector CANCardXL hardware from www.vector-cantech.com.  Vector is the standard benchmark for CAN tools but they are VERY expensive (~$1500US for a basic setup).  For this price you get support and apparently lots of experience and well mature tools. They also give you an API so you can write your own programs.  The API does not include a J2524 API.  Last time I looked (3 yrs ago) tThey want another $10,000US for the J2534 API.  That is just highway robbery!!!  This tool is optically isolated so you don't have to worry about blowing up your circuits.

2) ValueCAN3 from Intrepid at http://intrepidcs.com/osc_store/product_info.php/cPath/21/products_id/103.  This tool works well.  I have used the "Lite" version of the software which allows  you to monitor the CAN bus and also send some basic types of messages.  You can not do scripts with the "Lite" version. They do give you an API and a J2534 API so you can write your own computer program to interact with the tool.  I have written several programs and is very simple to do, especially with the free examples. If you are interesting in purchasing this I suggest you call them and ask them exactly what you get for $395.

3) MYCANIC tool at http://www.eepod.com.  This tool is ~$600.  It does not come with any interface software.  This tool is mainly used to write your own J2534 passthrough applications.  They give you the API and support is top notch.

Hope this helps.

Good luck!
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Mon Apr 04 11:26:42 MST 2011

Quote: rtos
This looks similar to the ValueCAN3 from Intrepid Control Systems.

http://intrepidcs.com/osc_store/product_info.php/cPath/21/products_id/103

I have used this tool and it works good.



ValueCAN3 is almost 3 times the price of the CANUSB, maybe PriceyCAN3 would be a better name.:)

Does it have features that make it that much better to be worth the extra money spent?

I'm looking for a good CAN tool as well and have to research this.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rtos on Mon Apr 04 10:42:56 MST 2011

Quote: Polux rsv
http://www.canusb.com/

The only complain is about good PC software to analyse communication. But for the low price, it is a good tool to start viewing what your project is doing on CAN lines.

Angelo



This looks similar to the ValueCAN3 from Intrepid Control Systems.

http://intrepidcs.com/osc_store/product_info.php/cPath/21/products_id/103

I have used this tool and it works good.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Mon Apr 04 04:26:52 MST 2011
http://www.canusb.com/

The only complain is about good PC software to analyse communication. But for the low price, it is a good tool to start viewing what your project is doing on CAN lines.

Angelo
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jlara on Sat Apr 02 05:27:02 MST 2011
Hi Angelo,

I searched for USBCAN tool and found many links.  Can you please post the link for the tool you are using?  Do you have any complaints about it?

Thanks!
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Mar 31 05:13:29 MST 2011

Quote:
...what CAN tool do you use?


[INDENT]A few years ago a white-bearded man wearing a red coat brought me a PicoScope2203.
Nice little USB toy :)

Price: $262.35 / €192.39

http://www.picotech.com/picoscope2200-specifications.html

Its 'SerialDecoding' can decode CAN, I2C, UART and SPI.
Use 'watch video':

http://www.picotech.com/picoscope6-serial-decoding.html

[/INDENT]
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Mar 31 04:42:23 MST 2011
[U][B]Sample Point Calculation:[/B][/U]

In this sample TSEG1 & TSEG2 are register values, so (TSEG1+1) is the 'real' time value.

Sample Point = ((TSEG1 +1) + 1) / TBITTIME = ((15 +1) + 1) / 24 = [B][COLOR=red]0.71[/COLOR][/B]
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jlara on Thu Mar 31 03:50:52 MST 2011
Thanks NXP Fairy  :)

If the following is correct, is to correct to understand the sample point@ 66%?  Should have RTM :D

TBITTIME = (TSEG1 +1) + (TSEG2 + 1) + TSYNC = 24

Instead, I thought that

TBITTIME = TSEG1 + TSEG2 +1

I was trying to learn to calculate these parameters in case I need to change the sample point to a desired value.  Thanks for the great help!!!
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jlara on Wed Mar 30 19:57:53 MST 2011
Hello Zero, NXP,

Can you please let me know if you agree with the following BTR calculations?

PLL = 72MHz
CAN Baudrate: 500KHz
Tq = 18
TSEG1 = 14
TSEG2 = 3
SJW = 3
BRP = 1


TSEG1 = 14, TSEG2 = 3, BRP = 2
CANxBTR = 0x003EC001     Is this correct?  If not, can you be so kind as to point to the error and why it is incorrect.

If anyone from NXP, CodeRed, or EA is moderating this forum, any input would be appreciated, as well as any useful links.

Zero, what CAN tool do you use?  The tool you posted a while ago of a CAN message looks nice.  It appears you have a scope which can decode a CAN message ID, data bytes, etc.  I am in the market for a good tool if it is affordable.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Mar 29 05:12:52 MST 2011
1. In 'local self test' mode no second CAN node is required. If you connect a CAN transceiver to your LPC it's transmitting, regardless what is or isn't connected.
That's a good way to start :):)

2. 'Listen only mode' or 'silent mode' doesn't acknowledge received messages in order to read data in existing systems (like cars) without interfering them. In this mode a transmitting node doesn't detect acknowledge and restarts transmission.

3. It's important to understand some basic features of CAN. Transmitting a CAN message (in normal mode) always implies to detect an acknowledge at the end of the message.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Tue Mar 29 04:55:01 MST 2011
The last post of Zero let me remember you must have at least 2 nodes on the bus. I had some problems, not sure if they were the same than yours, but when I put the USBCAN tool in "listen only" mode, I got some errors. When a node send a message, all present nodes send ack at the end. I don't know if this indication could help you.

But anyway, using the powerfull debugger, you could/should step each line of code and check if CAN registers are set correctly, following the reference manual.
In few letters, RTFM :D.

Angelo
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Mar 29 03:43:02 MST 2011
To start a new hardware switch to 'local self test' before you enter your main loop:
[LEFT]//set local self test[/LEFT]
LPC_CAN1->MOD = 1; // Enter Reset Mode
LPC_CAN1->MOD = (1<<2); //local self test

So you don't need an acknowledge and avoid problems with your receiving hardware.
Just use a timer to transmit each 100ms and scope it.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jlara on Tue Mar 29 03:31:28 MST 2011
Hi Zero, Angelo,

The "lpc17_CAN__LedControl" code only result in error frames from CAN1 with my LPCXpresso 1768.  I am using a reputable tool to monitor the bus (Vector CANalyzer).  Also monitoring with a scope and I can see messages back to back on the oscilloscope. 

Even if I transmit only one frame (call to CAN_SendMsg), the CAN controller will continuously transmit error frames.  For termination, I have a 120ohm resistor between CAN Hi and CAN Lo.

I already made the changes posted by Angelo in this thread.  Do  you have any other suggestions for things to try? What is causing the error frames?

Thanks in advance.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Mar 25 06:58:01 MST 2011
Are you just crying or do you want to get your CAN running?

The link above shows an example :) Did you try this? Our your clueless friend?

So stop crying and describe your problem...
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rtos on Fri Mar 25 06:26:05 MST 2011

Quote: Polux rsv
I built a CAN gateway using both can controllers, with filters. Works perfectly, but some important bugs must be corrected in lpc17xx_can.c. And some limitations apply if you want two different bitrate. Read this post

Angelo



I wrote the original post for that thread and to this day I can not get the CAN code to work.  There are too many sample CAN code examples floating around that "almost work" or "should work" or have "stipulations to work " with the LPC1768 Expresso board.  Not knowing a whole lot about the details of setting up CAN it's difficult to follow along and get these slightly our of spec demo codes to work properly.  I've spend countless hours and still cant get the CAN code to work.  Maybe it's just me or I'm not as smart as the rest of you guys.  I've even showed these code samples to a friend that knows a fair amount about CAN and he could not get the code to work with the LPC1786 board.

I wish that one of you guys who have the CAN code working on an actual LPC1768 board could post your known good working code in a project form for the LPC1768Expresso board.  Perhaps just distill it down to a simple send/receive example.  This way when I run it it will just work out of the box and I can then focus on learning why it works instead of spinning endlessly trying to debug an example that was written for another development environment and does not really work, etc.  That would be MUCH appreciate and very kind of you!
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Polux rsv on Thu Mar 24 01:32:36 MST 2011
I built a CAN gateway using both can controllers, with filters. Works perfectly, but some important bugs must be corrected in lpc17xx_can.c. And some limitations apply if you want two different bitrate. Read this post

Angelo
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Mar 23 22:56:29 MST 2011

Quote: Ajay
Zero,

Have you tried the code attached in your reply?



Yes, the attached pictures shows it.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ajay on Wed Mar 23 19:34:00 MST 2011
Zero,

Have you tried the code attached in your reply?  I saw a comment from CodeRed that it was untested code.  I am asking so that if I run into issue, I know someone can help.  I am surprised the example code does not include a CAN example.
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Mar 23 16:52:48 MST 2011
Try:

lpc17_CAN__LedControl.zip

http://support.code-red-tech.com/CodeRedWiki/NXPDriverLibraries

See:

http://knowledgebase.nxp.com/showthread.php?p=5962
0 Kudos
Reply

2,413 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Wed Mar 23 16:43:56 MST 2011
Hi Ajay,

I'm sure that Zero has.  Be a little more specific about the problems you are having.
0 Kudos
Reply