CAN TD Problem LPCXpresso 1769

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

CAN TD Problem LPCXpresso 1769

5,854 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Thu Oct 11 03:15:57 MST 2012
Hi,

Currently I am using the folowing setup:
[LIST]
[*]LPCXpresso 1769
[*]Computer Connected to Kvaser Eagle
[*]MCP2551 CAN Transceiver (interface between above mentioned items)
[/LIST]

A schematic of how I connected the transceiver to my Xpresso is included. Also a picture of my setup is included.

As a startoff project I used:
http://www.lpcware.com/content/nxpfile/mcb1700-sample-code-bundle-lpc1769-peripherals-using-lpcxpres...

Project name: CAN

I did not modify anything.

When I transmit a message from my Kvaser to my Xpresso, I can see on my scope that RD is receiving a nice logic signal, which is 5V when my kvaser Eagle is not transmitting anything.

However my Eagle keeps retransmitting because it does not get an acknowledgement. I am reading error flagx 0x20, which indicates and Error frame. This is a flag which I also receive when the eagle is not connected to any CAN BUS.

I cannot read anything on my TD bus except for a constant 3.0V signal. When I remove my Xpresso this signal is 5V because the MCP2551 has a pull-up resistor.

I tried different PINMODE0 settings for the TD port without any success.

When I am trying to run the program on my Xpresso, it transmits a message. But after that it gets stuck in this loop:

[FONT=Courier New]
while ( !(LPC_CAN1->GSR & (1 << 3)) );
cantest.c line 193
[/FONT]


I don't have any experience regarding CAN and their transceivers. This as much as I figured out on my own.

Your help would be greatly appreciated.

I already searched the forum extensively, but it is hard to try and test all CAN libraries and tests posted on this forum. Therefore I'm starting a fresh topic and hoping someone can help me out. Maybe there is a very simple solution.

Kind regards,

Joep Roebroek
0 Kudos
Reply
16 Replies

5,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tarik1985 on Fri Nov 16 10:40:42 MST 2012
hello,

i am beginner in LPCXpresso lpc1769, and i want  to do a program in language C which can receive a data from CANbus to my PC in txt file but i don't know where i can develop it and how to begin


thank you
0 Kudos
Reply

5,811 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Oct 19 06:16:40 MST 2012

Quote: Mindblaze
As I interpret this image, TD is Acknowledging the incoming signal RD with a 0V pulse. Is this correct?




Yes, this is an classic ACK
How transceiver work is easier to understand if you scope CAN-H against RD / TD.

This pictures show a received, transmitted and ACKed CAN frame:

http://flic.kr/p/dkJ96Q
http://flic.kr/p/dkJ6Qv
http://flic.kr/p/dkJ991

Probably your code is wrong :p
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Fri Oct 19 05:12:11 MST 2012
In the image attached you can see what RD and TD do.

RD is yellow, this is the output RXD of the transceiver
TD is blue, this is the output of the LPCXpresso to TXD of the transceiver.

As I interpret this image, TD is Acknowledging the incoming signal RD with a 0V pulse. Is this correct?

However the LPCXpresso doesn't seem to do an interrupt in the code. I really don't get what is going wrong.....
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Oct 18 02:22:48 MST 2012
I'm not sure what you are talking about :)

Do you know how CAN is working? Are we talking about ACK at TD :confused:

Scoping signals (CAN-H against RD or TD) is showing you what's happening ;)
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Thu Oct 18 00:58:39 MST 2012

Quote: Zero
Probably this function is providing a Bypass mode also ;)

Edit:   CAN_SetACCF( ACCF_BYPASS );



Sorry for not checking that first, before posting a reply so quicly

Considering my status: The long RC-time was due to a defect in the measuring probe :(. So it now copies the signal nicely, however with 3.3V logic signals, but this is obvious because the Xpresso is a 3.3V unit.

When I put it back in normal mode however LPC_CAN1->MOD = 0; Every time the Kvaser repeats the message on the CAN the Xpresso puts a 0 on the TD port. This looks like he is trying to post a confirm, but I'm not sure. The MCP2551 however doesn't seem to do anything with it. So I'll just wait for the NXP transceivers to arrive.

What I do find strange is that regardless of the confirm 0, the CANRx1Done bool never reaches true.... But this is something I will investigate later on.

Thanks for your support so far!
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 17 04:53:58 MST 2012
Probably this function is providing a Bypass mode also ;)

Edit:   CAN_SetACCF( ACCF_BYPASS );
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Wed Oct 17 04:33:46 MST 2012

Quote: Zero
CAN-BUS (=wires) and it's termination :)  (Is it terminated :confused: And if so, how?)



This is not measured on the bus. It is measured on the TD and RD pin. The RD pin shows a nice 0 and 5V logic signal. The TD pin replicates the RD signal, however this is 0 and 3V levels and has a long RC time.

The CAN bus itself is terminated using 2 x 120 Ohm resistors. And when I measure this on the scope there is a nice logic differential signal.


Quote: Zero
CAN_SetACCF( ACCF_ON );



How can I bypass acceptance filtering? I already tried setting it to ACCF_FULLCAN. Or shouldn't I call the function at all?
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Oct 17 04:22:11 MST 2012

Quote:
So my questions are:
    What causes this long RC-time?

CAN-BUS (=wires) and it's termination :)  (Is it terminated :confused: And if so, how?)


Quote:

So my questions are:
Why doesn't it process the received signal, i.e. Put the message received bool (CAN1RxDone) on 1? The interrupt is not called.

CAN_SetACCF( ACCF_ON );

Are you familiar with Acceptance Filter? If not, bypass it ;)
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Wed Oct 17 03:37:17 MST 2012
Hi,

I did some more debugging:

First I wanted to check if the signal that was put on the RD pin was processed so I made the following in my main.c:

[FONT=Courier New]MsgBuf_RX1.Frame = 0x0;
  MsgBuf_RX1.MsgID = 0x0;
  MsgBuf_RX1.DataA = 0x0;
  MsgBuf_RX1.DataB = 0x0;
  CAN_SetACCF( ACCF_ON );

  while ( 1 )
  {
        // Check if message has been received
if ( CAN1RxDone == TRUE )
{
  CAN1RxDone = FALSE;
  /* Everything is correct, reset buffer */
  MsgBuf_RX1.Frame = 0x0;
  MsgBuf_RX1.MsgID = 0x0;
  MsgBuf_RX1.DataA = 0x0;
  MsgBuf_RX1.DataB = 0x0;
} /* Message on CAN 2 received */
  }
[/FONT]
This should work when the kvaser is sending messages, but when i put a breakpoint in the if statement it never fires. CAN mode is set to 0

Then, I looked up CAN Mode in the manual and it said there is a Test Mode when you set bit 7 to 1. What this mode does is simply copy the input at RD to the output at TD.

This works! However the TD signal has a very long slope (large RC-time) and it only reaches 3V max (but this is what you explained the NXP LPC1769 works with 3V logic levels).

So my questions are:

[LIST]
[*]What causes this long RC-time?
[*]Why doesn't it process the received signal, i.e. Put the message received bool (CAN1RxDone) on 1? The interrupt is not called.
[/LIST]

Thanks for your help so far!
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Oct 11 07:49:02 MST 2012

Quote:

LPC_CAN1->MOD returns 0x5 in the expression watch, so my transceiver is probably broken?

No :eek:

5 = 4 + 1 = Self Test Mode + Reset Mode :)

Switch Self Test Mode if all settings are done, just before you enable CAN Interrupt ;)

In Reset Mode CAN isn't working :mad:

Note: MCP2551 is a 5V transceiver,  if you change your transceiver use a 5V transceiver for 3.3V devices (TJF1051) or a real 3.3V transceiver (3.3V supply) like SN65HVD23x.
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Thu Oct 11 07:37:37 MST 2012
Thanks for your reply.

I did what you said:

[FONT=Courier New]uint32_t CAN_Init( uint32_t can_btr )
{
  CAN1RxDone = CAN2RxDone = FALSE;

  LPC_SC->PCONP |= ((1<<13)|(1<<14));  /* Enable CAN1 and CAN2 clock */

  LPC_PINCON->PINSEL0 &= ~0x0000000F;  /* CAN1 is p0.0 and p0.1*/
  LPC_PINCON->PINSEL0 |=  0x00000005;
  LPC_PINCON->PINSEL4 &= ~0x0003C000;  /* CAN2 is p2.7 and p2.8 */
  LPC_PINCON->PINSEL4 |=  0x00014000;

  LPC_PINCON->PINMODE0 &= ~0x0000000F;
  LPC_PINCON->PINMODE0 |=  0x00000002;


  LPC_CAN1->MOD = LPC_CAN2->MOD = 1;    /* Reset CAN */
  LPC_CAN1->IER = LPC_CAN2->IER = 0;    /* Disable Receive Interrupt */
  LPC_CAN1->GSR = LPC_CAN2->GSR = 0;    /* Reset error counter when CANxMOD is in reset*/

  LPC_CAN1->MOD = (1<<2); //local self test

  LPC_CAN1->CMR = (0x1<<1) | // Abort transmission bit
                  (0x1<<2) | // Release receive buffer
                  (0x1<<3);  // Clear data overrun bit

  LPC_CAN1->BTR = LPC_CAN2->BTR = can_btr;
  //LPC_CAN1->MOD = LPC_CAN2->MOD = 0x0;  /* CAN in normal operation mode */

  NVIC_EnableIRQ(CAN_IRQn);

  LPC_CAN1->IER = LPC_CAN2->IER = 0x01; /* Enable receive interrupts */
  return( TRUE );
}[/FONT]

LPC_CAN1->MOD returns 0x5 in the expression watch, so my transceiver is probably broken?

My transceivers RD signal still works however, so this is very strange. But I will make sure that I get some new transceivers.

Thanks for your help!

Regards,

Joep Roebroek
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Oct 11 06:47:34 MST 2012
No :eek:

'Local Self Test' is described in UM and #4 of http://knowledgebase.nxp.com/showthread.php?p=5962

It's used to test 1 channel

#1 without transceiver :)

#2 with transceiver without other nodes (= without acknowledgement) :)

If you try to get debug access to your target again you have to pull low ISP pin and reset your target (= pin 17 low) or cycle power ;)
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Thu Oct 11 06:31:09 MST 2012
I'm guessing you mean: testing whether it communicates between CAN1 and CAN2?

Well, I am trying to set that up now, but the problem is that I'm getting a debug error and I don't know why this started happening.

Image is included.

I searched for a while and I did the following without any results:
* enabled vector catch
* GND the ISP pin (P2.10) and assert RST (I don't know what that means, but I put RESET_N on +5V)

I'm getting really frustrated...
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Oct 11 03:48:50 MST 2012
What's the result of Local Self Test?
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Mindblaze on Thu Oct 11 03:43:39 MST 2012
Yes, they are, this is default in the CAN project that was provided:

[FONT=Courier New]LPC_PINCON->PINSEL0 &= ~0x0000000F;  /* CAN1 is p0.0 and p0.1*/
LPC_PINCON->PINSEL0 |=  0x00000005;
LPC_PINCON->PINSEL4 &= ~0x0003C000;  /* CAN2 is p2.7 and p2.8 */
LPC_PINCON->PINSEL4 |=  0x00014000;[/FONT]

The usermanual indicates that 01 indicates that the port should be used for CAN.
0 Kudos
Reply

5,809 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Oct 11 03:30:01 MST 2012
Which CAN setup are you using?

Are P0.0 and P0.1 setup as CAN?
0 Kudos
Reply