使用我们的多端口I/O扩展器优化您的控制系统和智能解决方案的效率,实现精确的输入和输出管理,以进行数据调节和节能。
A
A
硬件概览
它是如何工作的?
Expand 15 Click基于TCAL6416,这是德州仪器的一款通用I/O扩展器。TCAL6416采用一个P端口配置,通过标准I2C串行接口轻松添加I/O。其数字核心包括8位数据寄存器,允许用户配置I/O端口特性。I/O在上电或复位后配置为输入。然而,主控制器可以通过写入配置寄存器将I/O配置为输入或输出。每个输入或输出的数据保存在相应的输入端口或输出端口寄存器中,可以通过极性反转寄存器反转输入端口的极性。配置为输出的P端口通道可以吸收高达25mA的电流以直接驱动LED,但必须通过附加电阻限制电流。
此外,TCAL6416具有专门针对增强I/O端口的Agile I/O功能,包括可编程输出驱动强度、可编程上拉和下拉电阻、可锁存输入、可屏蔽中断、中断状态寄存器以及可编程开漏或推挽输出。这些配置寄存器通过增加灵活性来改进I/O,使用户能够优化其设计以减少功耗、提高速度和降低EMI。该Click板™通过标准I2C 2线接口与MCU通信,以读取数据和配置设置,最高频率为1MHz。此外,TCAL6416允许使用标记为ADDR SEL的SMD跳线选择其I2C从设备地址的最低有效位(LSB)。它还具有一个通用复位信
号,连接到mikroBUS™插座的RST引脚,以复位TCAL6416,并且在输入端口状态变化时,连接到mikroBUS™插座的INT引脚的附加中断信号。此Click板™只能在3.3V逻辑电压水平下运行。此外,通过标记为VCCP SEL的跳线,可以选择TCAL6416的电源,以使用1.08V到3.6V的外部电源(V引脚)或3V3 mikroBUS™电源轨。使用不同逻辑电平的MCU之前,必须进行适当的逻辑电压电平转换。此外,该Click板™配备了包含易于使用功能和示例代码的库,可用作进一步开发的参考。
功能概述
开发板
PIC32MZ Clicker 是一款紧凑型入门开发板,它将 Click 板™的灵活性带给您喜爱的微控制器,使其成为实现您想法的完美入门套件。它配备了一款板载 32 位带有浮点单元的 Microchip PIC32MZ 微控制器,一个 USB 连接器,LED 指示灯,按钮,一个 mikroProg 连接器,以及一个用于与外部电子设备接口的头部。得益于其紧凑的设计和清晰易识别的丝网标记,它提供了流畅且沉浸式的工作体验,允许在任
何情况下、任何地方都能访问。PIC32MZ Clicker 开 发套件的每个部分都包含了使同一板块运行最高效的必要组件。除了可以选择 PIC32MZ Clicker 的编程方式,使用 USB HID mikroBootloader 或通过外部 mikroProg 连接器为 PIC,dsPIC 或 PIC32 编程外,Clicker 板还包括一个干净且调节过的开发套件电源供应模块。USB Micro-B 连接可以提供多达 500mA 的电流,这足以操作所有板载和附加模块。所有
mikroBUS™ 本身支持的通信方法都在这块板上,包 括已经建立良好的 mikroBUS™ 插槽、重置按钮以及若干按钮和 LED 指示灯。PIC32MZ Clicker 是 Mikroe 生态系统的一个组成部分,允许您在几分钟内创建新的应用程序。它由 Mikroe 软件工具原生支持,得益于大量不同的 Click 板™(超过一千块板),其数量每天都在增长,它涵盖了原型制作的许多方面。
微控制器概述
MCU卡片 / MCU

建筑
PIC32
MCU 内存 (KB)
1024
硅供应商
Microchip
引脚数
64
RAM (字节)
524288
使用的MCU引脚
mikroBUS™映射器
“仔细看看!”
Click board™ 原理图

一步一步来
项目组装
实时跟踪您的结果
应用程序输出
1. 应用程序输出 - 在调试模式下,“应用程序输出”窗口支持实时数据监控,直接提供执行结果的可视化。请按照提供的教程正确配置环境,以确保数据正确显示。

2. UART 终端 - 使用UART Terminal通过USB to UART converter监视数据传输,实现Click board™与开发系统之间的直接通信。请根据项目需求配置波特率和其他串行设置,以确保正常运行。有关分步设置说明,请参考提供的教程。

3. Plot 输出 - Plot功能提供了一种强大的方式来可视化实时传感器数据,使趋势分析、调试和多个数据点的对比变得更加直观。要正确设置,请按照提供的教程,其中包含使用Plot功能显示Click board™读数的分步示例。在代码中使用Plot功能时,请使用以下函数:plot(insert_graph_name, variable_name);。这是一个通用格式,用户需要将“insert_graph_name”替换为实际图表名称,并将“variable_name”替换为要显示的参数。

软件支持
库描述
该库包含 Expand 15 Click 驱动程序的 API。
关键功能:
expand15_hw_reset
- Expand 15硬件复位功能expand15_get_in_pin_state
- Expand 15获取输入引脚状态功能expand15_set_out_pin_state
- Expand 15设置输出引脚状态功能
开源
代码示例
完整的应用程序代码和一个现成的项目可以通过NECTO Studio包管理器直接安装到NECTO Studio。 应用程序代码也可以在MIKROE的GitHub账户中找到。
/*!
* @file main.c
* @brief Expand 15 Click example
*
* # Description
* This example demonstrates the use of Expand 15 click board by setting and reading
* the ports state.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration which sets
* half of the port 0 and port 1 pins as output ( P00, P02, P04, P06, P10, P12, P14 and P16) and the
* half of the port 0 and port 1 pins as inputs ( P01, P03, P05, P07, P11, P13, P15 and P17).
*
* ## Application Task
* Sets the state of the output pins of one port and then reads the status of input pins of that port
* and displays the results on the USB UART approximately 2 seconds.
*
* @note
* In order for this example to work as intended it is necessary to connect the input and output pins
* eg. P00 and P01, P02 and P03 etc. Floating input pins will be shown as a high state.
*
* @author Stefan Ilic
*
*/
#include "board.h"
#include "log.h"
#include "expand15.h"
static expand15_t expand15;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
expand15_cfg_t expand15_cfg; /**< Click config object. */
/**
* 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.
expand15_cfg_setup( &expand15_cfg );
EXPAND15_MAP_MIKROBUS( expand15_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == expand15_init( &expand15, &expand15_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( EXPAND15_ERROR == expand15_default_cfg ( &expand15 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - \r\n" );
}
void application_task ( void )
{
uint8_t output_pin_state;
uint8_t input_pin_state;
// Setting port0 output pin ( P00, P02, P04 and P06 ) to high
output_pin_state = EXPAND15_PIN_00_MASK | EXPAND15_PIN_02_MASK | EXPAND15_PIN_04_MASK | EXPAND15_PIN_06_MASK;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_0, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port0
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_0, &input_pin_state );
log_printf( &logger, "OUTPUT PINS HIGH \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P01 : %c |", ( ( input_pin_state & EXPAND15_PIN_01_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P03 : %c |", ( ( input_pin_state & EXPAND15_PIN_03_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P05 : %c |", ( ( input_pin_state & EXPAND15_PIN_05_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P07 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_07_MASK ) ? 'H' : 'L' ) );
Delay_ms( 500 );
// Setting port0 output pin ( P00, P02, P04 and P06 ) to low
output_pin_state = EXPAND15_ALL_PINS_OFF;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_0, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port0
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_0, &input_pin_state );
log_printf( &logger, "OUTPUT PINS LOW \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P01 : %c |", ( ( input_pin_state & EXPAND15_PIN_01_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P03 : %c |", ( ( input_pin_state & EXPAND15_PIN_03_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P05 : %c |", ( ( input_pin_state & EXPAND15_PIN_05_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P07 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_07_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - \r\n" );
Delay_ms( 2000 );
// Setting port1 output pin ( P10, P12, P14 and P01 ) to high
output_pin_state = EXPAND15_PIN_10_MASK | EXPAND15_PIN_12_MASK | EXPAND15_PIN_14_MASK | EXPAND15_PIN_16_MASK;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_1, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port1
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_1, &input_pin_state );
log_printf( &logger, "OUTPUT PINS HIGH \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P11 : %c |", ( ( input_pin_state & EXPAND15_PIN_11_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P13 : %c |", ( ( input_pin_state & EXPAND15_PIN_13_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P15 : %c |", ( ( input_pin_state & EXPAND15_PIN_15_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P17 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_17_MASK ) ? 'H' : 'L' ) );
Delay_ms( 500 );
// Setting port1 output pin ( P10, P12, P14 and P16 ) to low
output_pin_state = EXPAND15_ALL_PINS_OFF;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_1, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port1
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_1, &input_pin_state );
log_printf( &logger, "OUTPUT PINS LOW \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P11 : %c |", ( ( input_pin_state & EXPAND15_PIN_11_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P13 : %c |", ( ( input_pin_state & EXPAND15_PIN_13_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P15 : %c |", ( ( input_pin_state & EXPAND15_PIN_15_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P17 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_17_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - \r\n" );
Delay_ms( 2000 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END