Our new website is available at new.dizzy.co.za :-).

X
+27 (0)11 022 5323 +27 (0)64 681 8495
Basket/Checkout
R
- -
MagnifierSearch:
I2C to SPI Click (Go to Parent Category)

I2C to SPI Click

I2C to SPi Click is an all-in-one solution which allows serving as an interface between a standard I2C-bus of a microcontroller and an SPi bus, which allows the microcontroller to communicate directly with SPi devices through its I2C-bus. It is equipped with the stacking headers, so it can be easily connected. By offering an I2C-bus slave-transmitter or slave-receiver and an SPi master, this Click board™ controls all the SPi bus-specific sequences, protocol, and timing. It also has its own internal oscillator, and it supports the SPi chip select output that may be configured as GPIO when not used.

I2C to SPi Click is supported by a mikroSDK compliant library, which includes functions that simplify software development. This Click board™ comes as a fully tested product, ready to be used on a system equipped with the mikroBUS™ socket.

R285  Qty:
Price ex. VAT. Weight: 18g. Stock: Lead-time applicable [i]. mikroE Icon

When it comes to communicating between chips on a printed circuit board, two protocols are extremely popular: Serial Peripheral Interface (SPi) and Inter-Integrated Circuit (IIC or I2C). They are both serial protocols with a shared bus supporting multiple devices, but they multiplex their lines very differently. However, both of them are extremely popular, as they are easy to implement, requiring few components and little code, over the other communication protocols. Both rely on serial communication to pass data and support multiple devices on one bus. Many microcontrollers, sensors, and peripherals rely on SPi and I2C to talk to each other. This Click board™ is a perfect solution for numerous needs, such as hand-held and portable equipment, PDAs, palmtops, digital cameras, and other devices that support I2C interface, offering the ability to communicate directly with SPi devices through its I2C-bus.

How does it work?

The design of the I2C to SPi Click is based around two SC18IS602B, an I2C-bus to SPi bridge from NXP. This IC bridges the data communication between the two interfaces, offering many additional features, such as the programmable I/O, internal oscillator option, active low interrupt output, low power mode, and more. The SC18IS602B operates as an I2C-bus slave-transmitter or slave-receiver and an SPi master. The SC18IS602B controls all the SPi bus-specific sequences, protocol, and timing. It also has its own internal oscillator, and it supports SPi chip select output that may be configured as GPIO when not used. This allows the software to be easily written or ported from another platform.

The I2C to SPi Click provides a byte-oriented I2C-bus interface that supports data transfers up to 400 kHz. When the I2C-bus master is reading data from the click board™, the device will be a slave-transmitter. It also can be a slave-receiver when the I2C-bus master is sending data. The SC18IS602B acts as an I2C-bus master at no time. However, it does have the ability to hold the SCL line LOW between bytes to complete its internal processes.

A slave address of the SC18IS602B is comprised of a fixed and a programmable part. The programmable part of the slave address enables the maximum possible number of such devices to be connected to the I2C-bus. Since the SC18IS602B has three programmable address bits (defined by the A2, A1, and A0 pins), it is possible to have eight of these devices on the same bus. Therefore, this Click board™ is equipped with three SMD jumpers, grouped under the ADDR SEL label, used to select the I2C slave address. By moving the jumpers at the desired position, the user can select the address used for the communication with the host MCU.

The #RESET pin performs the hardware reset of the SC18IS602B IC. The #RESET pin is routed to the mikroBUS™ RST pin and it is active LOW. The #INT allows the host MCU to receive an interrupt from the SC18IS602B IC. An interrupt is generated by the SC18IS602B after any SPi transmission has been completed. Therefore, the #INT of the SC18IS602B is routed to the INT pin of the mikroBUS™ socket. The interrupt can be cleared (INT pin HIGH) by sending a ‘Clear Interrupt' command, although It is not necessary. This allows more optimized software (firmware) to be written, as the host MCU does not have to continuously poll the LSR register to see if any interrupt needs to be serviced.

The datasheet of the SC18IS602B offers more information about using and configuring the SC18IS602B IC. However, the Click board™ is supported by a mikroSDK library, offering functions that simplify the prototyping and firmware development.

This Click board™ is operated by 3.3V only. To be able to use it with MCUs that use 5V logic level on their communication lines, a proper level-translation circuit should be used.

Specifications

Type RS232
Applications This Click board™ is a perfect solution for battery powered hand-held and portable equipment, PDAs, palmtops, digital cameras, and other devices that still support the RS-232 standard, allowing them to communicate with any embedded application over the SPI or I2C interface, offering ESD protection
On-board modules MAX3237E, a 3.3V or 5V multichannel RS232, 1 Mbit/s line driver/receiver from Texas Instruments
Key Features It supports both I2C and SPI interfaces bridging them to UART, supports a lot of features including, Line-Break generation and detection, programmable special character detection, auto flow control (software and hardware), 15kV ESD protection, integrated RS-232 connector, etc.
Interface UART
Click board size L (57.15 x 25.4 mm)
Input Voltage 3.3V

Pinout diagram

This table shows how the pinout on I2C to SPi Click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).

Notes Pin Mikrobus logo.png Pin Notes
NC 1 AN PWM 16 NC
Reset RST 2 RST INT 15 INT Interrupt
Chip Select / A0 CS 3 CS RX 14 NC
SPI Clock SCK 4 SCK TX 13 NC
SPI Data OUT SDO 5 MISO SCL 12 SCL I2C Clock
SPI Data IN SDI 6 MOSI SDA 11 SDA I2C Data
Power Supply 3.3V 7 3.3V 5V 10 NC
Ground GND 8 GND GND 9 GND Ground

Onboard settings and indicators

Label Name Default Description
LD1 PWR - Power LED Indicator
JP1-JP3 ADDR SELL Left Communication interface selection: left position 0, right position 1

Software Support

We provide a library for the I2C to SPi Click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Library Description

The library covers all the necessary functions to control I2C to SPi click board. Library performs interface between a standard I2C-bus of a microcontroller and an SPi bus.

Key functions:

  • void i2ctospi_spiWriteByte( uint8_t slaveDevice, uint8_t functionId, uint8_t regAddr, uint8_t writeData ) - Generic SPI write the byte of data to data buffer function.
  • uint8_t i2ctospi_spiReadByte( uint8_t slaveDevice, uint8_t functionId, uint8_t regAddr ) - Generic SPI read the byte of data from data buffer function.
  • void i2ctospi_configSPI( uint8_t configData ) - Configure SPI Interface function.

Examples description

The application is composed of three sections :

  • System Initialization - Initializes GPIO, SPI and LOG structures, sets RST and CS pins as output and INT pin as an input.
  • Application Initialization - Initialization driver enable's - I2C, hardware reset, SS0 ( CS ) configured to be used as slave select outputs, set the configuration of SPI: order MSB first, clock Idle low, leading-edge transition, SPI clock rate to 115kHz, set SPI EEPROM write enable SS0, clear interrupt, clear RT5 register, sets starting time: hours, minutes and seconds ( enable counting ), also write log.
  • Application Task - (code snippet) This is an example which demonstrates the use of RTC 5 click is wired to I2C to SPI click board. I2C to SPI click communicates with register via the I2C interface, serve as an interface between a standard I2C-bus of a microcontroller and an SPI bus. RTC 5 click communicates with register via SPI interface. In this examples, we display RTC time which we received reading from the target register address of MCP79510 chip on RTC 5 click board via I2C interface of I2C to SPI click board. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on usb uart changes for every 1 sec.
void applicationTask()
{
    timeSeconds = _rtc5GetTimeSeconds();
    Delay_1ms();
    timeMinutes = _rtc5GetTimeMinutes();
    Delay_1ms();
    timeHours = _rtc5GetTimeHours();
    Delay_1ms();

    if ( timeSecondsNew != timeSeconds )
    {
        mikrobus_logWrite( " Time :  ", _LOG_TEXT );
    
        _displayLogUart( timeHours );
        mikrobus_logWrite( ":", _LOG_TEXT );
    
        _displayLogUart( timeMinutes );
        mikrobus_logWrite( ":", _LOG_TEXT );
    
        _displayLogUart( timeSeconds );
        mikrobus_logWrite( "", _LOG_LINE );
        
        mikrobus_logWrite( "------------------", _LOG_LINE );

        timeSecondsNew = timeSeconds;
    }

    Delay_1ms();
}


Additional Functions :

  • void _displayLogUart( uint8_t value ) - Write the value of time or date as a two-digit number.
  • void _rtc5Clear() - Clear RTCC and SRAM memory of RTC 5 click.
  • void _rtc5SetTimeSeconds( uint8_t seconds ) - Set the seconds and enable counting.
  • uint8_t _rtc5GetTimeSeconds() - Get the seconds.
  • void _rtc5SetTimeMinutes( uint8_t minutes ) - Set the minutes.
  • uint8_t _rtc5GetTimeMinutes() - Get the minutes.
  • void _rtc5SetTimeHours( uint8_t hours ) - Set the hours.
  • uint8_t _rtc5GetTimeHours() - Get the hours.

The full application code, and ready to use projects can be found on our LibStock page.

Other mikroE Libraries used in the example:

  • I2C
  • UART
  • Conversions

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.

mikroSDK

This Click board™ is supported with mikroSDK - MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.

For more information about mikroSDK, visit the official page.

Resources

Downloads