Bosch Can Users Guide For Cygnal Devices Keil Bosch CAN Users Guide for Cygnal Devices Keil This comprehensive guide will provide users with a detailed understanding of how to configure program and interact with Bosch CAN peripherals on Cygnal devices using the Keil development environment 1 CAN Controller Area Network is a widely used serial communication protocol for automotive and industrial applications Bosch offers a range of CAN transceivers and controllers that are compatible with various microcontrollers including Cygnal devices This guide will focus on utilizing Bosch CAN peripherals in conjunction with Keils integrated development environment IDE for seamless development and deployment of CANbased applications 2 Cygnal Devices and CAN Peripherals Cygnal devices renowned for their performance and versatility offer dedicated hardware blocks for CAN communication These peripherals are typically configured and controlled through dedicated registers within the devices memory map 3 Bosch CAN Transceivers and Controllers Bosch provides a diverse portfolio of CAN transceivers and controllers to suit various needs a Transceivers CAN2551 A lowpower highspeed CAN transceiver with differential inputs and outputs for robust communication CAN2552 Similar to CAN2551 but with an additional highvoltage output stage for enabling communication with higher voltage systems b Controllers CAN3320 An advanced CAN controller with integrated transceiver offering features like high speed operation up to 1 Mbps low power consumption and support for multiple CAN channels CAN3321 A costoptimized CAN controller with integrated transceiver offering features like highspeed operation up to 1 Mbps and low power consumption 2 4 Keil Development Environment Keils IDE provides a powerful platform for embedded development offering Project Creation and Management Easily set up and manage complex projects involving multiple source files and libraries Editor An intuitive and featurerich editor for writing editing and debugging C code Compiler and Linker Efficient and robust compiler and linker tools to generate optimized machine code for Cygnal devices Debugger Comprehensive debugging capabilities including stepbystep execution variable inspection and memory analysis CAN Driver Library Keil offers a prebuilt driver library specifically designed for interacting with Bosch CAN peripherals on Cygnal devices This library streamlines the development process by providing essential functions for configuring sending and receiving CAN messages 5 Setting Up Your Project 1 Create a New Project Launch Keil and create a new project selecting the appropriate Cygnal device as the target platform 2 Configure the CAN Peripheral Within your project settings locate the CAN peripheral configuration options You will need to specify Mode of Operation Select whether the CAN peripheral will operate in normal loopback or silent mode Baud Rate Set the desired data transmission rate for the CAN bus Acceptance Filter Configure the filter to specify which CAN messages the device should receive 3 Include the CAN Driver Library Add the appropriate header files and source files from Keils CAN driver library to your project This will provide access to the librarys functions 4 Initialize the CAN Driver Initialize the CAN driver library using the provided functions specifying the configured parameters 6 Sending and Receiving CAN Messages a Sending 1 Construct a CAN Message Create a structure that represents the CAN message defining its identifier ID and data payload 2 Send the Message Use the CAN drivers transmission functions to send the constructed message to the CAN bus 3 b Receiving 1 Receive a CAN Message Use the CAN drivers reception functions to receive incoming CAN messages 2 Extract Message Data Analyze the received messages identifier and data payload for further processing within your application 7 Examples and Code Snippets Here are some code snippets to illustrate the basic usage of the CAN driver library Initialization c include CANh Include the CAN driver header file CANConfigt canConfig Mode CANMODENORMAL BaudRate CANBAUDRATE500K AcceptanceFilter 0x100 0x200 Example acceptance filter configuration 0x300 0x400 CANInitcanConfig Initialize the CAN driver with specified configuration Sending c CANMessaget message Id 0x123 Data 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 Example data payload CANTransmitmessage Send the message to the CAN bus Receiving c 4 CANMessaget receivedMessage if CANReceivereceivedMessage Check if a message is available Process the received message uint32t id receivedMessageId uint8t data receivedMessageData 8 Troubleshooting and Debugging Data Consistency Ensure your CAN messages are formatted correctly including the identifier and data payload to avoid errors Baud Rate Matching Verify that the baud rate configured on the Cygnal device matches the baud rate set on the other devices communicating on the CAN bus Acceptance Filter Configuration Ensure your acceptance filter settings correctly match the identifiers of messages you intend to receive Peripheral Conflicts Be mindful of potential conflicts when using multiple CAN peripherals within your system Keil Debugger Utilize the Keil debugger to step through your code inspect variables and analyze memory contents to identify potential issues 9 Conclusion This guide provides a comprehensive foundation for using Bosch CAN peripherals on Cygnal devices with the Keil development environment By understanding the principles of CAN communication leveraging the Keil driver library and carefully configuring the peripherals you can successfully implement robust and reliable CANbased applications on your Cygnal systems