Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CAN bus protocol in LPC2368

Status
Not open for further replies.

mehran123

Member level 1
Joined
Aug 9, 2011
Messages
36
Helped
0
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,514
hi
I want to make a connection with CAN between 2 LPC2368s.
I used these codes:
#include "config.h"
#include "lcd.h"
#include <intrinsics.h>

unsigned int i=0,delay=0;
unsigned int d=0;

#pragma vector=0x1c
__fiq __arm void can (void)
{
lcdwrite('o');
lcdwrite('k');
CAN1CMR =0x00000004; //Release Receive Buffer
}
void main (void)
{
PINSEL0=0x00000000;
lcdint();
//---------intiallize CAN1---------//
PINSEL0 |=0x1; //set P0.0 to RD1
PINSEL0 |=(0x1<<2); //set P0.1 to TD1
PCONP |=(0x1<<13); //Power up CAN Controller 1
CAN1MOD =0x1; //set CAN1 MODE Reg. in Reset Mode
CAN1BTR =0x0B; //set Baud Rate Prescaler
CAN1BTR |=(0x05<<16); //set TESG1
CAN1BTR |=(0x02<<20); //set TESG2
CAN1MOD =0x00000000; //set CAN1 MODE Reg. in Operating Mode
CAN1IER =0x00000001; //Active Receive Interrupt
//---------intiallize Interrupt---------//
VICINTSELECT|=(1<<23); //set CAN1&2 interrupt in FIQ
VICINTENABLE|=(1<<23); //Enable CAN1&2 interrupt
__enable_interrupt();
//---------intiallize Acceptance Filter---------//
AFMR =0x00000003; //set Acceptance Filter in AccOff and AccBP
//--------transfer data-----------//
CAN1TFI1 =0x00040000; //set Frame Information:
//DLC=4 byte
//ID=11 bit
for(i=1;i<0x00000100;i=i<<1)
{
CAN1TID1=i; //set Identifire
if(CAN1SR&0x00000004)
{
delay=0;
CAN1TDA1=i; //copy data into the TDA
CAN1CMR=0x0000021; //Select Tx Buffer 1 ans dend data
}
for(delay=0;delay<0xA000;delay++);
}
while(1);
}
//----------------end of file-------//

but when i programmed the chip,it doesn't work
i tried AFMR =0x00000002 instead of AFMR =0x00000003,but it didn't solve the problem
what do you think?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top