mfahadsheikh
Newbie level 4

I copied the code for CAN BUS... from the book "Advanced PIC microcontroller projects"... Dogan Ibrahim... It is compiled and gives no error in MikroC Compiler but when i simulate that program on Proteus, i get an error "Read of Can Controller Register 0x0F6E(CANSTAT) returns last value stored". May anyone help me why this error occurs?
I have tried on my side and found that if i comment the functions used to initialize CAN Controller
e.g //Initialise CAN
CANInitialize(SJW,BRP,Phase_Seg1,Phase_Seg2,Prop_S eg,init_flag);
CANSetOperationMode(CAN_MODE_CONFIG,0xFF);
mask=-1;
CANSetMask(CAN_MASK_B1,mask,CAN_CONFIG_STD_MSG);
CANSetMask(CAN_MASK_B2,mask,CAN_CONFIG_STD_MSG);
CANSetFilter(CAN_FILTER_B2_F3,44,CAN_CONFIG_STD_MS G); //panic id==44
CANSetOperationMode(CAN_MODE_NORMAL,0xFF);
... no error occurs in simulation... else the error sustains... Kindly reply soon.
I have tried on my side and found that if i comment the functions used to initialize CAN Controller
e.g //Initialise CAN
CANInitialize(SJW,BRP,Phase_Seg1,Phase_Seg2,Prop_S eg,init_flag);
CANSetOperationMode(CAN_MODE_CONFIG,0xFF);
mask=-1;
CANSetMask(CAN_MASK_B1,mask,CAN_CONFIG_STD_MSG);
CANSetMask(CAN_MASK_B2,mask,CAN_CONFIG_STD_MSG);
CANSetFilter(CAN_FILTER_B2_F3,44,CAN_CONFIG_STD_MS G); //panic id==44
CANSetOperationMode(CAN_MODE_NORMAL,0xFF);
... no error occurs in simulation... else the error sustains... Kindly reply soon.