I am using an embedded artist LPC2478 board which has 2 CAN controllers. We have tried loading the sample code for CAN making all the necessary changes. We are facing the following problems when running the code in simulation mode. 1) transmit buffer shows the data to be sent only in the reset mode. 2)TxERR shows an error count of 7F 3)The ERRBIT says Start of frame error. 4)Reciever buffer does not recieve the data sent inspite of releasin the reciever buffer. I am attatching the code i used while simulation we have refrained from using the libraries provided and have configured the peripheral on our own to send a simple message from one controller to the 2nd.
#include<LPC24xx.h> #include<stdio.h> #include<math.h> #include <stdint.h> int main(void) { int i; PCONP|=(1<<13)|(1<<14); PINSEL0=0x0A05; CAN1MOD|=(1<<0); // running the controller in reset mode to write into registers CAN2MOD|=(1<<0); CAN_AFMR=(1<<1);// bypassing acceptance filters CAN1BTR=0x0C;//baudrate prescale CAN2BTR=0x0C; while((CAN1GSR & (1<<2))==0);//checking for empty transmit buffers CAN1CMR|=(1<<4)|(1<<5);//running can 1 in self reception mode and transmit buffer 1 CAN1TFI1=0x80000;//frame info CAN1TID1=0x0A;//id CAN1TDA1=0X0F;//data while(1) { for(i=0;i<10000;i++); CAN1MOD=0x00000000;//putting can in operation mode CAN2MOD=0x00000000; CAN1CMR|=(1<<0);//setting transmit request bit while((CAN1GSR & (1<<3))==0);//checking for reciever status CAN1CMR|=(1<<2); //releasing reciever buffer while((CAN2GSR & (1<<3))==0); CAN2CMR|=(1<<2); for(i=0;i<1000;i++);//delay } }
we are finding the statement with the transmit request (in bold) most problematic. we have referred to a lot of documentation regarding the protocol.
HELP NEEDED URGENTLY.