-
1CAN module
The CAN module comprise of a CAN controller and transceiver which establish the HIGH-LOW field lines for communication.Configure the module to transmit or receive data.Although CAN controller has 114 register which is configured using 8 types of command:
1.)RESET:-
mcp2515_RESET()
{
SetSS(0); //select slave
Send(MCP_RESET); //write reset instruction
SetSS(1); //unselect the slave
delay(10);}
2.)READ:-
mcp2515_READ_Byte(unsigned char address)
{
unsigned char res;
SetSS(0);
Send(0x03);
Send(address);
res = Recive();
SetSS(1);
delay(10);
return res;
}3.)WRITE:-
mcp2515_WRITE_Byte(unsigned char address,unsigned char data)
{
unsigned char dummy;
SetSS(0);
dummy =Send(0x02);
dummy =Send(address);
dummy =Send(data);
SetSS(1);
delay(10);
return dummy;
}4.)BIT MODIFY:-
mcp2515_modify(unsigned char address,unsigned char mask,unsigned char data)
{
SetSS(0);//slave select
Send(MCP_BITMOD); //0x05 ,command to modify bit
Send(address);//address of the register
Send(mask); //mask byte
Send(data); //data byte
SetSS(1); //unselect slave}
5.)READ STATUS:-
mcp2515_readStatus(void)
{
return mcp2515_readXXStatus_helper(MCP_READ_STATUS);
}6.)Recieve Status
7.)Read RX Buffer
8.)Load TX Buffer
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.