LPC11C14 C_CAN on-chip drivers

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC11C14 C_CAN on-chip drivers

696件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mschuffe on Wed May 25 01:41:34 MST 2011
can everbody explain the setup of the mask into the CAN_MSG_OBJ

typedef struct _CAN_MSG_OBJ {
  uint32_t  mode_id;                        /* CAN idenifier*/         
  uint32_t  mask;                             /* setup for the mask ? */
  uint8_t   data[8];                          /* Data field */        
  uint8_t   dlc;                                 /* Length of data field in bytes DLC */  
  uint8_t   msgobj;                          /* Message object number 1-32*/     
}CAN_MSG_OBJ;


Thanks in advance,
Best Regards, Maik
0 件の賞賛
返信
8 返答(返信)

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zsander on Thu May 26 14:39:05 MST 2011
I got it working with my temperature sensor now. The only difference that I found between your code and my code is with the mode_id, where you set all the bits, where mine worked with the bits cleared. I don't know why, but it worked for me.

[LEFT]msg_obj.msgobj = 1;
[B]msg_obj.mode_id = CAN_MSGOBJ_EXT[/B];
msg_obj.mask = 0x0;[/LEFT]
(*rom)->pCAND->config_rxmsgobj(&msg_obj);
 
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu May 26 12:00:39 MST 2011
Are you familiar with CAN?

1. Disconnect your sensor and transmit/receive successful a 29-bit message (with correct baudrate).

Therefore you have to use Loop-back mode (blue is new):

[COLOR=Blue]#define LOOP_BACK                        //use CAN LOOPBACK

//CAN TEST[/COLOR] [COLOR=Blue]
#define SILENT  3
#define LBACK    4
//CAN Control
#define TST    7[/COLOR]

/* Initialize the CAN controller */
 (*rom)->pCAND->init_can(&ClkInitTable[0], 1);
/* Configure the CAN callback functions */
 (*rom)->pCAND->config_calb(&callbacks);
/* Enable the CAN Interrupt */
[COLOR=Blue]#ifdef LOOP_BACK
  LPC_CAN->CNTL |= (1<< TST);            //enable test mode
  LPC_CAN->TEST |= (1<< LBACK);            //set LOOP TEST
  //LPC_CAN->TEST |= (1<< SILENT);        //set SILENT TEST
#endif[/COLOR]

NVIC_EnableIRQ(CAN_IRQn);
Setup 29-bit receive object:

#define CAN_MSGOBJ_EXT 0x20000000UL // CAN 2.0b 29-bit ID

// Configure message object 1 to receive all 29-bit messages
 msg_obj.msgobj = 1;
 msg_obj.mode_id = 0x1FFFFFFF | CAN_MSGOBJ_EXT;
 msg_obj.mask = 0x000;
 (*rom)->pCAND->config_rxmsgobj(&msg_obj);
and transmit 29-bit object:

// Send a simple one time CAN message 
 msg_obj.msgobj  = 0;
 msg_obj.mode_id = 0x345 | CAN_MSGOBJ_EXT;  // CAN 2.0b 29-bit ID;
 msg_obj.mask    = 0x0;
 msg_obj.dlc     = 4;
 msg_obj.data[0] = 'T';    //0x54
 msg_obj.data[1] = 'E';    //0x45
 msg_obj.data[2] = 'S';    //0x53
 msg_obj.data[3] = 'T';    //0x54
 (*rom)->pCAND->can_transmit(&msg_obj);
Set a breakpoint in CAN_rx() and you're receiving you own message.

2. Set correct baudrate.

3. Switch off Loop-back mode and reconnect sensor.
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zsander on Thu May 26 10:29:38 MST 2011
I'm using a LPC11C24.  I'm basically using the can_onchip example.  I'm just recieving a message from a temperature sensor that uses 29-bit can messaging.  I have an oscilloscope connectd to it, and it is transmitting a message back.  What settings would allow the CAN portion to recieve a message but not send it to the MPU?
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu May 26 10:20:19 MST 2011
Sorry, can't follow you. Don't know what mcu, what example you are using and also don't know what you are trying to receive and who is transmitting :confused:
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zsander on Thu May 26 10:11:21 MST 2011
I couldn't find it anywhere in a manual, but I also had to set the 30th bit for it to send 29-bit messages. I ran into another problem, in my STAT register, the RXOK bit is being set, meaning that "a message has been successfully recieved independent of the result of acceptance filtering". Any ideas what I might be doing wrong?  I thought I set it up to recieve all messages.[FONT=Arial][SIZE=1]
[/SIZE][/FONT]
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 25 14:01:53 MST 2011
Change it from 11-bit to 29-bit :)
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by zsander on Wed May 25 13:52:53 MST 2011
How would you modify that to accept 29-bit messages?
0 件の賞賛
返信

606件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 25 02:23:05 MST 2011
I don't think that 'everybody' can't explain this

Usage is shown in examples:

/* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */
    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x400;
    msg_obj.mask = 0x700;
What's unclear there?

Note: To receive every 11-bit message, use:
msg_obj.id = 0x7FF;
msg_obj.mask = 0x000;
0 件の賞賛
返信