Intermediate
30 min

Be the best in high-speed CAN industrial applications with ATA6570 and STM32F031K6

Embrace the future with CAN technology

ATA6570 Click with Nucleo 32 with STM32F031K6 MCU

Published Oct 01, 2024

Click board™

ATA6570 Click

Dev Board

Nucleo 32 with STM32F031K6 MCU

Compiler

NECTO Studio

MCU

STM32F031K6

Empower high-speed data exchange with our advanced CAN transceiver, revolutionizing automotive communication

A

A

Hardware Overview

How does it work?

ATA6570 Click uses the ATA6570, a standalone high-speed CAN transceiver IC from Microchip, with partial networking support. This IC supports CAN and recently established CAN FD protocols, up to 1Mbit/s and 5Mbit/s, respectively. The communication inside the CAN bus is differential and performed through the twisted pairs with the characteristic impedance of 120Ω. The CANH and CANL drivers drive the differential lines. This provides robustness and immunity to electromagnetic interferences, typically observed in automotive systems. The ISO 11898 standard defines a signal line of twisted-pair cable as the network topology, terminated by the resistors with the characteristic impedance of the CAN bus (120Ω) at both ends - to prevent signal reflection. The dominant/recessive states are used for the message priority arbitration - the node which transmits the signal with the higher priority (the lower the binary message identifier number, the higher the priority) will win the arbitration, and the node with the lower priority will abort the transmission, waiting for the bus to become available again. Since the high logic level on the CAN line is considered recessive, the TXD line has an internal pull-up resistor, making the ATA6570 device stay recessive if the pin is left floating. The ATA6570 device can be driven in the recessive or dominant state with the TXD pin: when the TXD pin is at the VCC level and works in Normal mode, the drivers at the CANH and CANL pins are turned off. These pins are biased at 2.5 (VCC/2), with respect to the GND, provided by the internal autonomous bus biasing circuitry, and the CAN driver is in a recessive state. Pulling the TXD pin to the GND will activate the CANH and CANL drivers and set the bus to the dominant state.

A TXD dominant timeout timer is started when the TXD pin is set to low. If the low state on the TXD pin persists for longer than the predetermined time, the transmitter will be disabled, releasing the bus lines to the recessive state. This function prevents the hardware or software failure from driving the bus lines to a permanent dominant state, blocking all network communications. When the device is in the Sleep or Unpowered mode, the drivers will become highly resistive, rendering the device passive and completely ignored by the CAN bus network. Although the RXD and TXD lines are interfaced with the microcontroller, the SPI bus sets the internal registers, such as the partial networking registers and other status and configuration-related registers. The provided MikroElektronika library contains functions to easily set the parameters via the SPI bus and establish communication with the nodes. Partial networking allows selective wake-up of ATA6570 Click. Dedicated predefined frames can wake the device if configured to accept these frames. For this reason, when the device is in Standby or Sleep mode, it will still actively monitor the bus for those frames. SPI can set the wake-up CAN frame ID and data. Besides waking up the device by the partial networking feature, the device can also be woken up by a remote wake-up pattern on the CAN bus or with the onboard switch connected to the WAKE pin of the ATA6570 IC. Another wake-up source can be the SPI command for those modes where the SPI module is active and the remote wake-up pattern on the CAN bus. When in Sleep, MCU Reset or Power Off mode, the INH pin, which is routed to the external regulators, will be turned off, reducing the power consumption of the

external elements. The #SHDN (shutdown) pins of the two LDO regulators found on the ATA6570 Click are connected to the INH pin. Both regulators take power from the car battery connector (VS pin), providing 5V and 3.3V for custom needs. Outputs of those LDOs are routed via the SMD jumpers that can be populated so that the LDOs can be used to power up the mikroBUS™ 3.3V and 5V power rails. However, it should be noted that MikroElektronika does not advise powering up its systems this way - that is why these jumpers are left unpopulated by default. Overtemperature mode is activated when the device's temperature becomes too high, and the device was previously working in Normal mode. The ATA6570 provides two levels of overtemperature protection. When the first temperature level threshold is reached, an alarm is in the form of an interrupt on the RX pin (if set) and an appropriate status bit. If the temperature rises, the device will shut down the CAN drivers. Microcontroller Reset mode utilizes an integrated watchdog. When the watchdog event occurs, it will trigger a pulse on the INH pin - this pin will be turned off for a predetermined period, performing a power cycle reset on all devices connected via the ATA6570 click LDOs. This is a power cycle reset measure for a custom system powered via the mikroBUS™ socket. The onboard SMD jumper labeled as the VIO SEL selects which voltage rail of two LDO regulators will be used as the logic voltage level (SPI, UART). It offers voltage selection between 3.3V and 5V so that the click board™ can be interfaced with both the 3.3V and 5V capable MCUs.

ATA6570 Click hardware overview image

Features overview

Development board

Nucleo 32 with STM32F031K6 MCU board provides an affordable and flexible platform for experimenting with STM32 microcontrollers in 32-pin packages. Featuring Arduino™ Nano connectivity, it allows easy expansion with specialized shields, while being mbed-enabled for seamless integration with online resources. The

board includes an on-board ST-LINK/V2-1 debugger/programmer, supporting USB reenumeration with three interfaces: Virtual Com port, mass storage, and debug port. It offers a flexible power supply through either USB VBUS or an external source. Additionally, it includes three LEDs (LD1 for USB communication, LD2 for power,

and LD3 as a user LED) and a reset push button. The STM32 Nucleo-32 board is supported by various Integrated Development Environments (IDEs) such as IAR™, Keil®, and GCC-based IDEs like AC6 SW4STM32, making it a versatile tool for developers.

Nucleo 32 with STM32F031K6 MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

32

Silicon Vendor

STMicroelectronics

Pin count

32

RAM (Bytes)

4096

You complete me!

Accessories

Click Shield for Nucleo-32 is the perfect way to expand your development board's functionalities with STM32 Nucleo-32 pinout. The Click Shield for Nucleo-32 provides two mikroBUS™ sockets to add any functionality from our ever-growing range of Click boards™. We are fully stocked with everything, from sensors and WiFi transceivers to motor control and audio amplifiers. The Click Shield for Nucleo-32 is compatible with the STM32 Nucleo-32 board, providing an affordable and flexible way for users to try out new ideas and quickly create prototypes with any STM32 microcontrollers, choosing from the various combinations of performance, power consumption, and features. The STM32 Nucleo-32 boards do not require any separate probe as they integrate the ST-LINK/V2-1 debugger/programmer and come with the STM32 comprehensive software HAL library and various packaged software examples. This development platform provides users with an effortless and common way to combine the STM32 Nucleo-32 footprint compatible board with their favorite Click boards™ in their upcoming projects.

Click Shield for Nucleo-32 accessories 1 image

DB9 Cable Female-to-Female (2m) cable is essential for establishing dependable serial data connections between devices. With its DB9 female connectors on both ends, this cable enables a seamless link between various equipment, such as computers, routers, switches, and other serial devices. Measuring 2 meters in length, it offers flexibility in arranging your setup without compromising data transmission quality. Crafted with precision, this cable ensures consistent and reliable data exchange, making it suitable for industrial applications, office environments, and home setups. Whether configuring networking equipment, accessing console ports, or utilizing serial peripherals, this cable's durable construction and robust connectors guarantee a stable connection. Simplify your data communication needs with the 2m DB9 female-to-female cable, an efficient solution designed to meet your serial connectivity requirements easily and efficiently.

ATA6570 Click accessories image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
SPI Chip Select
PA4
CS
SPI Clock
PB3
SCK
SPI Data OUT
PB4
MISO
SPI Data IN
PB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
UART TX
PA10
TX
UART RX
PA9
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

ATA6570 Click Schematic schematic

Step by step

Project assembly

Click Shield for Nucleo-144 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo 32 with STM32F031K6 MCU as your development board.

Click Shield for Nucleo-144 front image hardware assembly
Nucleo 144 with STM32L4A6ZG MCU front image hardware assembly
Stepper 22 Click front image hardware assembly
Prog-cut hardware assembly
Stepper 22 Click complete accessories setup image hardware assembly
Nucleo-32 with STM32 MCU Access MB 1 - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
STM32 M4 Clicker HA MCU/Select Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for ATA6570 Click driver.

Key functions:

  • ata6570_write_reg - Write Register

  • ata6570_read_reg - Read Register

Open Source

Code example

This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.

/*!
 * \file 
 * \brief Ata6570 Click example
 * 
 * # Description
 * This application is interfaces a Controller Area Network (CAN) protocol controller and the physical two-wire CAN bus.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * In addition to this module is palced inside normal working mode cappable of tranmission and reception of data.
 * 
 * ## Application Task  
 * Tranismiter/Receiver task depend on uncommented code
  Receiver logging each received byte to the UART for data logging, while transmiter send message each
  2 seconds.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "ata6570.h"


// ------------------------------------------------------------------ VARIABLES

#define PROCESS_RX_BUFFER_SIZE 500

// #define DEMO_APP_RECEIVER
#define DEMO_APP_TRANSMITER

static ata6570_t ata6570;
static log_t logger;

static char demo_message[ 9 ] = { 'M', 'i', 'k', 'r', 'o', 'E', 13, 10, 0 };
static int32_t rsp_size;
static char uart_rx_buffer[ PROCESS_RX_BUFFER_SIZE ] = { 0 };

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    ata6570_cfg_t 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( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, "---- Application Init ----" );

    //  Click initialization.

    ata6570_cfg_setup( &cfg );
    ATA6570_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    ata6570_init( &ata6570, &cfg );
    ata6570_write_reg( &ata6570, ATA6570_DMCR, ATA6570_OPMODE_NORMAL );
    Delay_ms( 500 );
}

void application_task ( void )
{
    //  Task implementation.
    
#ifdef DEMO_APP_RECEIVER
       // RECEIVER - UART polling
      rsp_size = ata6570_generic_read( &ata6570, uart_rx_buffer, PROCESS_RX_BUFFER_SIZE );

      if ( rsp_size > 0 )
        {  
            log_printf( &logger, "%s", uart_rx_buffer );
            memset( uart_rx_buffer, 0, rsp_size );
        }  
#endif
       
#ifdef DEMO_APP_TRANSMITER
       // TRANSMITER - TX each 2 sec
       for( uint8_t i = 0; i < 8; i++ )
       {
           ata6570_generic_write( &ata6570, &demo_message[ i ], 1 );
       }
       Delay_ms( 2000 );
#endif
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.