We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2022-02-03
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: CAN
Downloaded: 5339 times
Not followed.
License: MIT license
MCP2518FD Click is a compact add-on board representing a complete CAN solution used as a control node in a CAN network. This board features the MCP2518FD, an external CAN FD controller with an SPI interface, and a high-speed CAN transceiver, the ATA6563, both from Microchip. The ATA6563, a low-level physical layer IC (PHY), provides a physical connection with the CAN bus itself, while the CAN controller MCP2518FD represents an interface between the MCU and the PHY. It features three operating modes with dedicated fail-safe features, remote wake-up via CAN, and ideally passive behavior when powered off on the CAN bus. This Click boardâ„¢ is suitable for developing a wide range of automotive diagnostic applications, even on MCUs that do not natively support CAN interface.
Do you want to subscribe in order to receive notifications regarding "MCP2518FD click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "MCP2518FD click" changes.
Do you want to report abuse regarding "MCP2518FD click".
Library Description
Library offers a choice to exchange messages with the other device by using CAN communication. Library also offers a choice to access a control, status and RAM registers of the device. For more details check documentation.
Key functions:
void MCP2518FD_transmitMessage( uint8_t numDataBytes, uint8_t *transmitFlag, uint8_t *dataIn )
- Transmits the desired message and checks is message successfully sent.void MCP2518FD_receiveMessage( uint8_t *receiveFlag, uint8_t *dataOut )
- Receives the message and checks is message successfully received.int8_t MCP2518FD_Configure(T_MCP2518FD_id index, T_MCP2518FD_cfg* config)
- CAN Control register configuration.int8_t MCP2518FD_ConfigureObjectReset(T_MCP2518FD_cfg* config)
- Reset Configure object to reset values.Examples description
The application is composed of the three sections :
void applicationTask()
{
if (UART_Rdy_Ptr())
{
rxDat = UART_Rd_Ptr();
chPtr = &txd[0];
switch (rxDat)
{
case '1' :
{
_strcpy( chPtr, &txtMessage1[0] );
MCP2518FD_transmitMessage( 5, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
case '2' :
{
_strcpy( chPtr, &txtMessage2[0] );
MCP2518FD_transmitMessage( 7, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
case '3' :
{
_strcpy( chPtr, &txtMessage3[0] );
MCP2518FD_transmitMessage( 2, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
case '4' :
{
_strcpy( chPtr, &txtMessage4[0] );
MCP2518FD_transmitMessage( 4, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
case '5' :
{
_strcpy( chPtr, &txtMessage5[0] );
MCP2518FD_transmitMessage( 3, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
case '6' :
{
_strcpy( chPtr, &txtMessage6[0] );
MCP2518FD_transmitMessage( 3, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
case '7' :
{
_strcpy( chPtr, &txtMessage7[0] );
MCP2518FD_transmitMessage( 7, &checkFlag, &txd[0] );
if (checkFlag == 1)
{
mikrobus_logWrite( "Message Sent", _LOG_LINE );
}
break;
}
default :
{
break;
}
}
}
MCP2518FD_receiveMessage( &checkFlag, &rxd[0] );
if (checkFlag == 1)
{
chPtr = &rxd[0];
mikrobus_logWrite( "Received Message : ", _LOG_TEXT );
mikrobus_logWrite( chPtr, _LOG_LINE );
}
}
Additional Functions :
Other mikroE Libraries used in the example:
SPI
UART
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.