Intermediate
30 min

Take charge of operations and restore settings with ease using QT1011 and PIC18LF27K42

Command and Safeguard

Power/Reset Click with Curiosity HPC

Published Jan 23, 2024

Click board™

Power/Reset Click

Dev Board

Curiosity HPC

Compiler

NECTO Studio

MCU

PIC18LF27K42

Effortlessly control device states with the ON/OFF button and, when needed, utilize the RESET button to restore settings to default swiftly, ensuring efficient management and seamless operation

A

A

Hardware Overview

How does it work?

Power/Reset Click is based on the QT1011, a digital burst mode charge-transfer sensor capable of detecting proximity or touch from Microchip. This click board™ has two PCB pads to sense touch or proximity events. Besides the two touch-sensitive pads, Power/Reset click has two LEDs for the touch indication. The two touch pads use two separate QT1011 ICs, providing reliable touch-sensing functionality. The AT42QT1011 is a digital burst mode charge-transfer sensor capable of detecting proximity or touch, making it ideal for implementing touch controls. With the proper electrode and circuit design, the self-contained digital IC will project a touch or proximity field to several centimeters through any dielectric like glass, plastic, stone, ceramic, and even most kinds

of wood. It can also turn small metal-bearing objects into intrinsic sensors responsive to proximity or touch. This capability and its ability to self-calibrate can lead to entirely new product concepts. The QT1011 is designed for human interfaces like control panels, appliances, toys, lighting controls, or anywhere a mechanical switch or button may be found. It includes all hardware and signal processing functions necessary to provide stable sensing under various changing conditions. However, this click board™ is designed to serve as a power and reset capacitive switch panel board. Besides the QT1011, this click board™ contains 74LVC1G74 as well. It is a Single D-type flip-flop with set and reset. Because the output of the QT1011 is active-high upon detection, the

74LVC1G74 is triggered by the positive edge of the ON/OFF touchpad. It is wired in a cascade with the QT1011 in a way that ensures holding one logical state until the ON/OFF pad is pressed. Therefore, the ON/OFF pad acts like a switch, while the RESET pad acts like a button, which is suitable for most common purposes. The ON/OFF and RESET pad output signals are wired to the PWM and INT pins on the mikroBUS™, respectively. Besides that, the STAT and RST LEDs are wired parallel to the outputs to ensure a visible indication of the status of the pins. This Click board™ is designed to be operated only with a 3.3V logic level. A proper logic voltage level conversion should be performed before the Click board™ is used with MCUs with logic levels of 5V.

Power/Reset Click hardware overview image

Features overview

Development board

Curiosity HPC, standing for Curiosity High Pin Count (HPC) development board, supports 28- and 40-pin 8-bit PIC MCUs specially designed by Microchip for the needs of rapid development of embedded applications. This board has two unique PDIP sockets, surrounded by dual-row expansion headers, allowing connectivity to all pins on the populated PIC MCUs. It also contains a powerful onboard PICkit™ (PKOB), eliminating the need for an external programming/debugging tool, two mikroBUS™ sockets for Click board™ connectivity, a USB connector, a set of indicator LEDs, push button switches and a variable potentiometer. All

these features allow you to combine the strength of Microchip and Mikroe and create custom electronic solutions more efficiently than ever. Each part of the Curiosity HPC development board contains the components necessary for the most efficient operation of the same board. An integrated onboard PICkit™ (PKOB) allows low-voltage programming and in-circuit debugging for all supported devices. When used with the MPLAB® X Integrated Development Environment (IDE, version 3.0 or higher) or MPLAB® Xpress IDE, in-circuit debugging allows users to run, modify, and troubleshoot their custom software and hardware

quickly without the need for additional debugging tools. Besides, it includes a clean and regulated power supply block for the development board via the USB Micro-B connector, alongside all communication methods that mikroBUS™ itself supports. Curiosity HPC development board allows you to create a new application in just a few steps. Natively supported by Microchip software tools, it covers many aspects of prototyping thanks to many number of different Click boards™ (over a thousand boards), the number of which is growing daily.

Curiosity HPC double image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

28

RAM (Bytes)

8192

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
NC
NC
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
ON/OFF Status
RC2
PWM
Reset Status
RB5
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Schematic

Power/Reset Click Schematic schematic

Step by step

Project assembly

Curiosity HPC front no-mcu image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity HPC as your development board.

Curiosity HPC front no-mcu image hardware assembly
IR Sense 4 Click front image hardware assembly
MCU DIP 28 hardware assembly
Prog-cut hardware assembly
Curiosity HPC 28pin-DIP - 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
Necto DIP image step 7 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for Power/Reset Click driver.

Key functions:

  • powerreset_get_pwr - Power Check function

  • powerreset_get_rst - Reset Check function

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 Power Reset Click example
 * 
 * # Description
 * Reads PWR and RST pin states and performs a control of the timer counter depending on the pressed button.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes device and logger module, prints Initialization done message.
 * 
 * ## Application Task  
 * Checks the states of the PWR and RST pins and logs every change.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "powerreset.h"

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

static powerreset_t powerreset;
static log_t logger;

powerreset_state_t pwr_state;
powerreset_state_t rst_state;

powerreset_state_t new_pwr_state;
powerreset_state_t new_rst_state;

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

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

    powerreset_cfg_setup( &cfg );
    POWERRESET_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    powerreset_init( &powerreset, &cfg );

    Delay_ms( 100 );
    
    log_printf( &logger, "** Touch Button initialization done **\r\n");
    log_printf( &logger, "**************************************\r\n");
}

void application_task ( void )
{
    new_pwr_state = powerreset_get_pwr( &powerreset );
    new_rst_state = powerreset_get_rst( &powerreset );
    
    if ( new_pwr_state != pwr_state )
    {
        if ( new_pwr_state == POWERRESET_ACTIVE )
        {
            log_printf( &logger, "POWER ON\r\n" );
            Delay_ms( 100 );
        }
        else if ( new_pwr_state == POWERRESET_INACTIVE )
        {
            log_printf( &logger, "POWER OFF\r\n" );
            Delay_ms( 100 );
        }
        pwr_state = new_pwr_state;
    }

    if ( new_rst_state != rst_state )
    {
        if ( new_rst_state == POWERRESET_ACTIVE )
        {
            log_printf( &logger, "Reset occured!\r\n" );
            Delay_ms( 100 );
        }
        rst_state = new_rst_state;
    }
}

void main ( void )
{
    application_init( );

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

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

Additional Support

Resources