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.

Looking for C code for CAN bus for PIC18F458

Status
Not open for further replies.

shoqeen

Newbie level 3
Joined
Dec 17, 2009
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
pakistan
Activity points
1,298
help

Does anyone have 'C' code for initialising the CAN Bus controller within the PIC18F458 Microcontroller.
:?:
 

use mikroC software from Mikroelectronica. its demo version is free.
it hs got all the functions of CAN inbuilt. all u gotta do is call these function


//CAN timing
SJW=1;
BRP=1;
Phase_Seg1=6;
Phase_Seg2=7;
Prop_Seg=6;

//Flags
init_flag=CAN_CONFIG_SAMPLE_THRICE&
CAN_CONFIG_PHSEG2_PRG_ON&
CAN_CONFIG_STD_MSG&
CAN_CONFIG_DBL_BUFFER_ON&
CAN_CONFIG_VALID_STD_MSG&
CAN_CONFIG_LINE_FILTER_OFF;
send_flag=CAN_TX_PRIORITY_0&
CAN_TX_STD_FRAME&
CAN_TX_NO_RTR_FRAME;
read_flag=0;

//Initialise CAN
CANInitialize(SJW,BRP,Phase_Seg1,Phase_Seg2,Prop_Seg,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_MSG); //panic id==44
CANSetOperationMode(CAN_MODE_NORMAL,0xFF);


help files are too user friendly. u can customise any values easily
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top