Sir when I do Pinsel for CAN 1 RX which is 0x00040000 the board resets Please help me.I have attached the code below

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

Sir when I do Pinsel for CAN 1 RX which is 0x00040000 the board resets Please help me.I have attached the code below

662 Views
akhileshverneka
Contributor II

#include<lpc21xx.h>


char a[100]={1,3,5,7,9,11,13,15};
char b[100]={2,4,6,8,10,12,14,16};
char rxdata[8]={0,0,0,0,0,0,0,0};
char txdata[8]={0,0,0,0,0,0,0,0};
int flag=1;
unsigned int l,id;
unsigned int low,high;


void can_init()
{
PINSEL1 |= 0x00040000; can1 rx

AFMR=0x02; // All messages are received
C1MOD=0x01; // CAN is set to reset mode
C1IER=0x00; // Disabling all interrupts
C1RFS=0x00003000;
C1BTR=0x00270004; // Setting Baud rate to 500kbps , Baudrate Prescalar
C1MOD=0×00; // CAN is set to normal mode


}

void can_tx(char a[])
{

C1TFI1=0X00080000; // Data length code = 3 is set, RTR =0;
C1TID1=0X92; // Identifier is set to 34(dec)

C1TDA1=(a[0]) | (a[1]<<8) | (a[2]<<16) | (a[3]<<24); // 4 bytes of data is added
C1TDB1=(a[4]) | (a[5]<<8) | (a[6]<<16) | (a[7]<<24); //
C1CMR=0X21; // Transmission request and Transmitter buffer 1 is selected;

while((C1SR & 0x04 )!= 0x04); // wait till transmission is completed

}
void can_rx()
{
int i;
//while ((C1GSR & 0x00000010)!= 0x000000010)

flag=0;
// Checking if data is present in Rx buffer
if((C1RFS & 0x00000008)!=0x00000008)
{
l=C1RFS; // Length of the Received data
id=C1RID; // Stores the Identifier of the Rx msg into id
low=C1RDA; // Received data is stored in d
high=C1RDB;

for(i=0;i<4;i++)
{
txdata[i]=low<<(i*8);
}
for(i=4;i<8;i++)
{
txdata[i]=high<<(i*8);
}
}
else
C1CMR=0x04; // Releases the Rx buffer
}

int main()
{
can_init();

can_tx(a);


}

0 Kudos
4 Replies

601 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Akhilesh Vernekar ,

Please tell me which chip do you used, thank you.

Regards,

Alice

0 Kudos

601 Views
akhileshverneka
Contributor II

Lpc2129 board

0 Kudos

601 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Akhilesh,

Have you config the clock well ?

This chip is too old, I recommend you use new LPC products, there are many demos and

applications support new chips.

0 Kudos

601 Views
akhileshverneka
Contributor II

LPC2129 

0 Kudos