The ADuCM3029_demo_cn0401 project provides a solution to adding isolated fieldbus communication to a microcontroller circuit. The project demonstrates basic CAN FD communication, transmission and response to the ISO11898-2:2016 remote wake-up pattern, and control of switchable termination circuitry. The example code is written for the EVAL-ADICUP3029 development platform to control the EVAL-ADM3055E-ARDZ daughter board over the SPI bus interface. The daughter boards main component is the ADM3055E, an isolated signal and power CAN FD transceiver with integrated auxiliary channel.
The ADuCM3029_demo_cn0401 project uses the EVAL-ADM3055E-ARDZ to provide CAN FD bus connectivity to underlying development board that it may be added to an existing CAN FD bus as another node. This example demonstrates the EVAL-ADM3055E-ARDZ circuit features using two nodes, each a EVAL-ADM3055E-ARDZ and EVAL-ADICUP3029 development board.
The node is at first in low power mode by putting the CAN controller and transceiver to standby mode. The user can then issue a command to transmit an ASCII message on the bus. the message is repeated for 5 seconds or until it is acknowledged by another node, then the transmitting node goes to standby. If the system receives a message, particularly the slower baud rate arbitration phase, it wakes up, receives the message and displays it on the CLI terminal, then goes back to standby. A node not connected to a CAN bus can also run a self-test routine on the command of the user, in which it transmits and receives a message in loopback mode and displays a PASS of FAIL message. The initial baud rate is 500KHz for the arbitration phase and 2MHz for the data phase and the application acknowledges messages with the Standard ID (SID) of 0x300. The SID can be changed by user commands.
The application is controlled by the user with a CLI implemented using the serial UART core in the ADuCM3029 controller. The CLI is displayed on a connected PC using a serial terminal connection.
The program is divided in 2 parts: the setup part in which the present module is discovered and the main process.
To replicate the CAN FD bus described in the example both boards need to be connected to each other via the P1 or P4 connectors on the board and each in turn connected to the Arduino form factor headers of the ADICUP3029. Then each ADICUP3029 needs to be connected to the PC via USB to provide serial terminal CLI interface for each node.
The following is a list of items needed in order to replicate this demo.
Most of the configuration parameters can be found in the CAN controller API module. The CAN controller API will instantiate a handler that will determine the initial configuration of the node. The handler is instantiated by the initialization structure with the following form:
struct can_ctrl_init_param { struct spi_init_param can_ctrl_spi_init; bool con_iso_crc_en; bool con_store_in_tef_en; bool con_txq_en; uint8_t tef_fifo_size; /* Number of messages in TEF FIFO*/ bool tef_time_stamp_en; enum can_ctrl_fifo_plsize txq_plsize; uint8_t txq_fifo_size; /* Number of messages in TXQ FIFO */ uint8_t txq_tx_priority; /* 0 is lowest; 0x1f is highest */ uint8_t tx_fifo_nr; enum can_ctrl_fifo_plsize tx_fifo_plsize; uint8_t tx_fifo_size; /* Number of messages in FIFO */ uint8_t tx_fifo_priority; /* 0 is lowest; 0x1f is highest */ uint8_t rx_fifo_nr; enum can_ctrl_fifo_plsize rx_fifo_plsize; uint8_t rx_fifo_size; /* Number of messages in FIFO */ bool rx_fifo_tsen; uint8_t rx_flt_nr; uint16_t rx_sid_addr; enum can_ctrl_nominal_bitrate can_nbt; enum can_ctrl_data_bitrate can_dbt; enum can_ctrl_ssp_mode ssp_mode; };
The following is a non-exhaustive list that contains the most important parameters and their values:
enum can_ctrl_data_bitrate { BITRATE_DBT_500K, BITRATE_DBT_833K, BITRATE_DBT_1M, BITRATE_DBT_1M5, BITRATE_DBT_2M, BITRATE_DBT_3M, BITRATE_DBT_4M, BITRATE_DBT_5M, BITRATE_DBT_6M7, BITRATE_DBT_8M, BITRATE_DBT_10M };
enum can_ctrl_nominal_bitrate { BITRATE_NBT_125K, BITRATE_NBT_250K, BITRATE_NBT_500K, BITRATE_NBT_1M };
These parameters can be changed in the can_ctrl_get_config function from the can_obj_layer.c file.
A serial terminal is an application that runs on a PC or laptop that is used to display data and interact with a connected device (including many of the Circuits from the Lab reference designs). The device's UART peripheral is most often connected to a UART to USB interface IC, which appears as a traditional COM port on the host PC/ laptop. (Traditionally, the device's UART port would have been connected to an RS-232 line driver / receiver and connected to the PC via a 9-pin or 25-pin serial port.) There are many open-source applications, and while there are many choices, typically we use one of the following:
Before continuing, please make sure you download and install one of the above programs.
There are several parameters on all serial terminal programs that must be setup properly in order for the PC and the connected device to communicate. Below are the common settings that must match on both the PC side and the connected UART device.
In many instances there are other options that each of the different serial terminal applications provide, such as local line echo or local line editing, and features like this can be turned on or off depending on your preferences. This setup guide will not go over all the options of each tool, but just the minor features that will make it easier to read back data from the connected devices.
Example setup using Putty
Typing help or h after initial calibration sequence will display the list of commands and their short versions. Bellow is the short command list:
Command | Example | Description |
---|---|---|
General commands | ||
h | h | Display available commands. |
Communication commands | ||
ct <msg> | ct Hello world! | Send a message through the CAN bus. <msg> = Message to be sent. |
css <sid> | css 245 | Set standard ID for the CAN messages sent. <sid> = Standard ID in hexadecimal; between 0x000 and 0x3FF. |
cg | ct | Get received messages if any. |
test | test | Perform a loopback test. |
We recommend not opening the project directly, but rather import it into CrossCore Embedded Studios and make a local copy in your workspace.
The source code and include files of the ADuCM3029_demo_cn0401 can be found here:
The official tool we promote for use with the EVAL-ADICUP3029 is CrossCore Embedded Studio. For more information on downloading the tools and a quick start guide on how to use the tool basics, please check out the Tools Overview page.
For more detailed instructions on importing this application/demo example into the CrossCore Embedded Studios tools, please view our How to import existing projects into your workspace section.
For more detailed instructions on importing this application/demo example into the CrossCore Embedded Studios tools, please view our How to configure the debug session section.
Project structure includes:
End of Document
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
全部0条评论
快来发表一下你的评论吧 !