初学者
10 分钟

使用IDC10头和PIC18F26K40简化其他附加组件与mikroBUS™插座的连接

让兼容性不再是问题!

Adapter Click with EasyPIC v8

已发布 6月 24, 2024

点击板

Adapter Click

开发板

EasyPIC v8

编译器

NECTO Studio

微控制器单元

PIC18F26K40

毫不费力地将传感器、驱动程序和其他组件集成到您的项目设置中。

A

A

硬件概览

它是如何工作的?

Adapter Click是一个适配器板,简化了将具有IDC10头部的附加组件连接到mikroBUS™插座的过程。一个2x5位置、2.54mm间距的连接器头部允许您以符合项目需求的方式添加传感器、驱动程序和各种组件。每个头部引脚对应于mikroBUS™插座上的一个引脚(除了AN和RST引脚)。多亏了这些引脚,与Click板™的连接始终牢固稳定,始终保持完美的连接质量。建立 这种连接有两种方式:男性或女性IDC10连接器。两

者都包含在包装中。您可以将男性IDC10连接器焊接在Adapter Click的顶部,并直接连接附加板或通过IDC10平线电缆连接。在某些情况下,女性头部插座可能是更好的选择。根据实际情况的方便程度,将其焊接在顶部或底部。Adapter Click允许使用I2C和SPI接口,其中每个mikroBUS™线都覆盖,除了如前所述 的AN和RST线。可以通过将标记为INTERFACE SELECTION的跳线放置在标记为SPI或I2C的适当位

置来进行选择。请注意,所有跳线的位置必须在同一侧,否则Click板™可能会失去响应。这个Click板™可以通过PWR SEL跳线选择3.3V和5V逻辑电压电平。这样,既支持3.3V又支持5V的MCU可以正确地使用通信线路。此外,这个Click板™配备了一个包含易于使用的函数和示例代码的库,可用作进一步开发的参考。

Adapter Click hardware overview image

功能概述

开发板

EasyPIC v8 是一款专为快速开发嵌入式应用的需求而特别设计的开发板。它支持许多高引脚计数的8位PIC微控制器,来自Microchip,无论它们的引脚数量如何,并且具有一系列独特功能,例如首次集成的调试器/程序员。开发板布局合理,设计周到,使得最终用户可以在一个地方找到所有必要的元素,如开关、按钮、指示灯、连接器等。得益于创新的制造技术,EasyPIC v8 提供了流畅而沉浸式的工作体验,允许在任何情况下、任何地方、任何时候都能访问。

EasyPIC v8 开发板的每个部分都包含了使同一板块运行最高效的必要组件。除了先进的集成CODEGRIP程 序/调试模块,该模块提供许多有价值的编程/调试选项和与Mikroe软件环境的无缝集成外,该板还包括一个干净且调节过的开发板电源供应模块。它可以使用广泛的外部电源,包括电池、外部12V电源供应和通过USB Type-C(USB-C)连接器的电源。通信选项如USB-UART、USB DEVICE和CAN也包括在内,包括 广受好评的mikroBUS™标准、两种显示选项(图形和

基于字符的LCD)和几种不同的DIP插座。这些插座覆盖了从最小的只有八个至四十个引脚的8位PIC MCU的广泛范围。EasyPIC v8 是Mikroe快速开发生态系统的一个组成部分。它由Mikroe软件工具原生支持,得益于大量不同的Click板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作和开发的许多方面。

EasyPIC v8 horizontal image

微控制器概述 

MCU卡片 / MCU

default

建筑

PIC

MCU 内存 (KB)

64

硅供应商

Microchip

引脚数

28

RAM (字节)

3728

使用的MCU引脚

mikroBUS™映射器

NC
NC
AN
NC
NC
RST
SPI Chip Select
RA5
CS
SPI Clock
RC3
SCK
SPI Data OUT
RC4
MISO
SPI Data IN
RC5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
PWM Signal
RC1
PWM
Interrupt
RB1
INT
UART TX
RC6
TX
UART RX
RC7
RX
I2C Clock
RC3
SCL
I2C Data
RC4
SDA
Power Supply
5V
5V
Ground
GND
GND
2

“仔细看看!”

原理图

Adapter Click Schematic schematic

一步一步来

项目组装

EasyPIC v8 front image hardware assembly

从选择您的开发板和Click板™开始。以EasyPIC v8作为您的开发板开始。

EasyPIC v8 front image hardware assembly
LTE IoT 5 Click front image hardware assembly
MCU DIP 28 hardware assembly
LTE IoT 5 Click complete accessories setup image hardware assembly
EasyPIC v8 28pin-DIP Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
NECTO Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto DIP image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

实时跟踪您的结果

应用输出通过UART模式

1. 一旦代码示例加载完成,按下 "FLASH" 按钮将启动构建过程,并将其编程到创建的设置上。

2. 编程完成后,点击右上角面板中的工具图标,选择 UART 终端

3. 打开 UART 终端标签后,首先在选项菜单中检查波特率设置(默认是 115200)。如果该参数正确,通过点击 "CONNECT" 按钮激活终端。

4. 现在,终端状态从 Disconnected 变为绿色的 Connected,数据将显示在 Received data 字段中。

UART_Application_Output

软件支持

库描述

这个库包含Adapter Click驱动程序的API。

关键功能:

  • adapter_generic_write - 将数据写入到指定的寄存器。

  • adapter_generic_read - 从指定的寄存器读取数据。

开源

代码示例

这个示例可以在 NECTO Studio 中找到。欢迎下载代码,或者您也可以复制下面的代码。

/*!
 * \file 
 * \brief Adapter Click example
 * 
 * # Description
 * Adapter click is a breakout board which simplifies connection of add-on boards. 
 * There are two ways of establishing connection: using male or female IDC10 connectors. 
 * Male header must be soldered on the top side of Adapter Click to connect the add-on board 
 * directly or via flat cable. Female header can be soldered either on the top, or the bottom 
 * side, depending on which one is more convenient in given circumstances.  
 * There are two jumpers for SPI/I2C selection and one for selection of power supply range.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initalizes I2C or SPI driver and makes an initial log.
 * 
 * ## Application Task  
 * This is an example that shows the use of the Adapter click board (SPI mode -  set as default). 
 * In I2C mode we are reading internal temperature from another device (THERMO 5 click board).
 * In SPI mode example we are writing "mikroElektronika" to SRAM click board, 
 * and then reading from the same memory location.
 * 
 * ## Additional Functions
 *   - float thermo5_read_inter_temp ( adapter_t *ctx ) - 
 *     @description Function reads measurements made by internal diode.
 *   - void sram_write_byte ( adapter_t *ctx, uint32_t reg_address, uint8_t write_data ) - 
 *     @description Function writes the 8-bit data to the target 24-bit register address of 23LC1024 chip.
 *   - uint8_t sram_read_byte ( adapter_t *ctx, uint32_t reg_address ) -
 *     @description Function reads the 8-bit data to the target 24-bit register address of 23LC1024 chip.
 *
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "adapter.h"

#define THERMO5_INTER_DIO_DATA_HI_BYTE          0x00
#define THERMO5_INTER_DIO_DATA_LO_BYTE          0x29

#define SRAM_24BIT_DATA                         0x00FFFFFF
#define SRAM_CMD_WRITE                          0x02
#define SRAM_CMD_READ                           0x03

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

static adapter_t adapter;
static log_t logger;

char send_buffer[ 17 ] = { 'm', 'i', 'k', 'r', 'o', 'E', 'l', 'e', 'k', 't', 'r', 'o', 'n', 'i', 'k', 'a', ' ' };
char mem_data[ 17 ];
uint8_t n_cnt;

// ------------------------------------------------------ ADDITIONAL FUNCTIONS

float thermo5_read_inter_temp ( adapter_t *ctx )
{
    uint16_t inter_temp;
    uint8_t high_byte;
    uint8_t low_byte;
    float output;
    output = 0.0;
    
    adapter_generic_read ( ctx, THERMO5_INTER_DIO_DATA_HI_BYTE, &high_byte, 1 );
    adapter_generic_read ( ctx, THERMO5_INTER_DIO_DATA_LO_BYTE, &low_byte, 1 );

    inter_temp = high_byte;
    inter_temp <<= 8;
    inter_temp |= low_byte;
    inter_temp >>= 5;
    output = ( float )inter_temp;
    output *= 0.125;

    return output;
}

void sram_write_byte ( adapter_t *ctx, uint32_t reg_address, uint8_t write_data )
{
    uint8_t tx_buf[ 4 ];
    uint8_t rx_buf;
    
    reg_address &= SRAM_24BIT_DATA;
    
    tx_buf[ 0 ]  = ( uint8_t ) ( reg_address >> 16 );
    tx_buf[ 1 ]  = ( uint8_t ) ( reg_address >> 8 );
    tx_buf[ 2 ]  = ( uint8_t )   reg_address;
    tx_buf[ 3 ]  = write_data;
    
    adapter_generic_write( ctx, SRAM_CMD_WRITE, tx_buf, 4 );
}

uint8_t sram_read_byte ( adapter_t *ctx, uint32_t reg_address )
{
    uint8_t tx_buf[ 5 ];
    uint8_t rx_buf[ 5 ];
    uint8_t read_data;
    
    reg_address &= SRAM_24BIT_DATA;

    tx_buf[ 0 ] = SRAM_CMD_READ;
    tx_buf[ 1 ] = ( uint8_t ) ( reg_address >> 16 );
    tx_buf[ 2 ] = ( uint8_t ) ( reg_address >> 8 );
    tx_buf[ 3 ] = ( uint8_t )   reg_address;
    
    adapter_generic_transfer( ctx, tx_buf, 4, rx_buf, 1 );
    
    read_data = rx_buf[ 0 ];

    return read_data;
}

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

void application_init ( void )
{
    log_cfg_t log_cfg;
    adapter_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.

    adapter_cfg_setup( &cfg );
    ADAPTER_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    adapter_init( &adapter, &cfg );
}

void application_task ( void )
{
    float temp_value;

    if ( adapter.master_sel == ADAPTER_MASTER_SPI )
    {
        log_printf( &logger, " Writing text :\r\n" );
   
        for ( n_cnt = 0; n_cnt < 16; n_cnt++ )
        {
            sram_write_byte( &adapter, n_cnt, send_buffer[ n_cnt ] );
            Delay_ms ( 100 );
            log_printf( &logger, "%c", send_buffer[ n_cnt ] );
        }
    
    
        log_printf( &logger, "\r\n" );
        log_printf( &logger, " Read text :\r\n" );
        for ( n_cnt = 0; n_cnt < 16; n_cnt++ )
        {
            mem_data[ n_cnt ] = sram_read_byte( &adapter, n_cnt );
            Delay_ms ( 100 );
            log_printf( &logger, "%c", mem_data[ n_cnt ] );
        }   
        log_printf( &logger, "\r\n" );
        log_printf( &logger, "--------------------------\r\n" );
    
        Delay_ms ( 1000 );
    }
    else if ( adapter.master_sel == ADAPTER_MASTER_I2C )
    {
        temp_value = thermo5_read_inter_temp( &adapter );

        log_printf( &logger, " Thermo 5 internal temperature :  %.2f\r\n", temp_value );
        log_printf( &logger, "--------------------------\r\n" );
    
        Delay_ms( 2000 );
    }
}

void main ( void )
{
    application_init( );

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


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

额外支持

资源

喜欢这个项目吗?

'购买此套件' 按钮会直接带您进入购物车,您可以在购物车中轻松添加或移除产品。