Utilize the bidirectional serial communication capability, compliant with the ISO9141 standard, to enable effective diagnostics in automotive systems
A
A
Hardware Overview
How does it work?
ISO 9141 Click is based on the L9637, a monolithic bus driver designed to provide bidirectional serial communication in automotive diagnostic applications according to the specification "Diagnostic Systems ISO9141" from ST Microelectronics. The L9637 is also known as the K-Line Transceiver that provides a bidirectional link, called K, and a separate comparator, called L, to the related diagnosis bus that can be connected to a terminal labeled K and L on this Click board™. The K and L pins are protected against overvoltages and reverse battery conditions. All pins show high impedance characteristics during the lack of power supply or ground. The L9637 has a wide supply voltage range from 4.5V to 36V and several modes of operation like Standby Mode with low current consumption and overtemperature Shut-Down Mode. The overtemperature Shut-Down Mode switches OFF
the K output if the L9637's temperature increases above the thermal shut-down threshold. To reactivate K again, the temperature must decrease below the K switch ON temperature value. The outputs will be switched OFF and stay at high impedance to achieve no fault for the power supply undervoltage conditions. ISO 9141 Click communicates with MCU using the UART interface with the default baud rate of 9600bps and commonly used UART RX and TX pins for the data transfer. The UART input TX and output RX of K are associated with the logic voltage level from mikroBUS™ (VCC) with its integrated pull-up resistances. Also, the L comparator output pin LO has a pull-up resistance connected to VCC. All bus-defined inputs, L and K, have supply voltage-dependent thresholds and sufficient hysteresis to suppress line spikes. This Click board™ is easy to program because it does not require an
overly demanding configuration. Only what is necessary for the errorless work is the selection of the appropriate mode of operation, whether the Click board™ will work as a receiver or transmitter. In this way, the transmitter will send the data every 2 seconds while the receiving side will receive the data in a "byte-by-byte "format. This can also be seen in an example code that contains easy-to-use functions that may be used as a reference for further development. This Click board™ is designed to be operated with both 3.3V and 5V logic voltage levels that can be selected via VCC SEL jumper. This allows both 3.3V and 5V capable MCUs to use the UART communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.
Features overview
Development board
EasyAVR v7 is the seventh generation of AVR development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 16-bit AVR microcontrollers from Microchip and has a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyAVR v7 allows you to connect accessory boards, sensors, and custom electronics more
efficiently than ever. Each part of the EasyAVR v7 development board contains the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-12V AC or 9-15V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B)
connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets which cover a wide range of 16-bit AVR MCUs. EasyAVR v7 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Architecture
AVR
MCU Memory (KB)
128
Silicon Vendor
Microchip
Pin count
40
RAM (Bytes)
16384
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Track your results in real time
Application Output
1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support
Library Description
This library contains API for ISO 9141 Click driver.
Key functions:
iso9141_generic_write
- This function writes a desired number of data bytes by using UART serial interfaceiso9141_generic_read
- This function reads a desired number of data bytes by using UART serial interfaceiso9141_send_data
- This function send data
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief ISO 9141 Click Example.
*
* # Description
* This example demonstrates the use of an ISO 9141 click board by showing
* the communication between the two click boards.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initalizes device and makes an initial log.
*
* ## Application Task
* Depending on the selected application mode, it reads all the received data or
* sends the desired text message once per second.
*
* @author MikroE Team
*
*/
#include "board.h"
#include "log.h"
#include "iso9141.h"
// Comment out the line below in order to switch the application mode to receiver
#define DEMO_APP_TRANSMITTER
// Text message to send in the transmitter application mode
#define DEMO_TEXT_MESSAGE "MIKROE - ISO 9141 click board\r\n\0"
static iso9141_t iso9141;
static log_t logger;
void application_init ( void )
{
iso9141_cfg_t iso9141_cfg;
log_cfg_t logger_cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( logger_cfg );
log_init( &logger, &logger_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
iso9141_cfg_setup( &iso9141_cfg );
ISO9141_MAP_MIKROBUS( iso9141_cfg, MIKROBUS_1 );
if ( UART_ERROR == iso9141_init( &iso9141, &iso9141_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
#ifdef DEMO_APP_TRANSMITTER
log_printf( &logger, " Application Mode: Transmitter\r\n" );
#else
log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
#ifdef DEMO_APP_TRANSMITTER
iso9141_generic_write( &iso9141, DEMO_TEXT_MESSAGE, strlen( DEMO_TEXT_MESSAGE ) );
log_printf( &logger, "%s", ( char * ) DEMO_TEXT_MESSAGE );
Delay_ms ( 1000 );
#else
uint8_t rx_byte = 0;
if ( 1 == iso9141_generic_read( &iso9141, &rx_byte, 1 ) )
{
log_printf( &logger, "%c", rx_byte );
}
#endif
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* @file main.c
* @brief ISO 9141 Click Example.
*
* # Description
* This example demonstrates the use of an ISO 9141 click board by showing
* the communication between the two click boards.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initalizes device and makes an initial log.
*
* ## Application Task
* Depending on the selected application mode, it reads all the received data or
* sends the desired text message once per second.
*
* @author MikroE Team
*
*/
#include "board.h"
#include "log.h"
#include "iso9141.h"
// Comment out the line below in order to switch the application mode to receiver
#define DEMO_APP_TRANSMITTER
// Text message to send in the transmitter application mode
#define DEMO_TEXT_MESSAGE "MIKROE - ISO 9141 click board\r\n\0"
static iso9141_t iso9141;
static log_t logger;
void application_init ( void )
{
iso9141_cfg_t iso9141_cfg;
log_cfg_t logger_cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( logger_cfg );
log_init( &logger, &logger_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
iso9141_cfg_setup( &iso9141_cfg );
ISO9141_MAP_MIKROBUS( iso9141_cfg, MIKROBUS_1 );
if ( UART_ERROR == iso9141_init( &iso9141, &iso9141_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
#ifdef DEMO_APP_TRANSMITTER
log_printf( &logger, " Application Mode: Transmitter\r\n" );
#else
log_printf( &logger, " Application Mode: Receiver\r\n" );
#endif
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
#ifdef DEMO_APP_TRANSMITTER
iso9141_generic_write( &iso9141, DEMO_TEXT_MESSAGE, strlen( DEMO_TEXT_MESSAGE ) );
log_printf( &logger, "%s", ( char * ) DEMO_TEXT_MESSAGE );
Delay_ms ( 1000 );
#else
uint8_t rx_byte = 0;
if ( 1 == iso9141_generic_read( &iso9141, &rx_byte, 1 ) )
{
log_printf( &logger, "%c", rx_byte );
}
#endif
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END