Part Number: MSP430FR2633
Hi,
my customer use MSP430FR2633 as keyboard emulator. Main processor is connected to MSP with 4 lines: ROW1, ROW2, ROW3 – inputs for MSP, and 4th line as output.
It looks like a MSP430FR2633 pins, configured as digital inputs, become act as output and voltage is dropped to 1V. The source code file is attached below, video of oscilloscope is available here: https://txn.box.com/s/9f88vz6rss01rvpz7nndefyo9mwch9rc. There is some noise on oscilloscope, please pay no attention to this noise, is because bad connection of oscilloscope ground.
Short 0 impulse – is button polling from a host MCU. Long pulses with a voltage of 1V is our problem.
/* --COPYRIGHT--,BSD
* Copyright (c) 2016, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
//*****************************************************************************
// Development main.c for MSP430FR26xx_25xx
//
// This starter application initializes the CapTIvate touch library
// for the touch panel specified by CAPT_UserConfig.c/.h via a call to
// CAPT_appStart(), which initializes and calibrates all sensors in the
// application, and starts the CapTIvate interval timer.
//
// Then, the capacitive touch interface is driven by calling the CapTIvate
// application handler, CAPT_appHandler(). The application handler manages
// whether the user interface (UI) is running in full active scan mode, or
// in a low-power wake-on-proximity mode.
//
// The CapTIvate application handler will return true if proximity was
// detected on any of the sensors in the application, which is used here
// to control the state of LED2. LED1 is set while the background loop enters
// the handler, and is cleared when the background loop leaves the handler.
//
// \version 1.03.02.00
// Released on Wed, Feb 24, 2016 2:01:17 PM
//
//*****************************************************************************
#include <msp430.h> // Generic MSP430 Device Include
#include "driverlib.h" // MSPWare Driver Library
#include "captivate.h" // CapTIvate Touch Software Library
#include "CAPT_App.h" // CapTIvate Application Code
#include "CAPT_BSP.h" // CapTIvate EVM Board Support Package
unsigned char ucButtonPressStatus = 0;
void main(void)
{
//
// Initialize the MCU
// BSP_configureMCU() sets up the device IO and clocking
// The global interrupt enable is set to allow peripherals
// to wake the MCU.
//
WDT_A_hold(WDT_A_BASE);
BSP_configureMCU();
__bis_SR_register(GIE);
//
// Start the CapTIvate application
//
CAPT_appStart();
// Enable interrupts on ROW1-ROW3 ports
// Falling edge
P1IES |= (BIT4 | BIT6 | BIT7);
// Clear interrupts
P1IFG &= ~(BIT4 | BIT6 | BIT7);
// Enable interrupts
P1IE |= (BIT4 | BIT6 | BIT7);
// Set columns
COL1_HIGH;
LED_OFF;
__enable_interrupt();
//
// Background Loop
//
while(1)
{
//
// Run the captivate application handler.
// Update buttons state if proximity detected.
//
if(CAPT_appHandler()==true)
{
if(g_uiApp.pSensorList[0]->pCycle[0]->pElements[0]->bTouch)
{
ucButtonPressStatus |= BIT1;
}
else
{
ucButtonPressStatus &= ~BIT1;
}
if(g_uiApp.pSensorList[0]->pCycle[0]->pElements[1]->bTouch)
{
ucButtonPressStatus |= BIT2;
}
else
{
ucButtonPressStatus &= ~BIT2;
}
if(g_uiApp.pSensorList[0]->pCycle[0]->pElements[2]->bTouch)
{
LED_ON;
ucButtonPressStatus |= BIT3;
}
else
{
ucButtonPressStatus &= ~BIT3;
LED_OFF;
}
}
else
{
// no proximity - no press
ucButtonPressStatus = 0;
}
__no_operation();
//
// End of background loop iteration
// Go to sleep if there is nothing left to do
//
CAPT_appSleep();
} // End background loop
} // End main()
//
// Handle GPIO ports according keyboard scan algorithm to emulate 2x3 keypad by 5 GPIO
//
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
// ROW_1
if(P1IFG & BIT4) {
// Rising or falling edge?
if(P1IES & BIT4)
{
// Falling edge
// If button 1 pressed set COL_1 to low
if(ucButtonPressStatus & BIT1)
{
COL1_LOW;
}
// set rising edge interrupt
P1IES &= ~(BIT4);
}
else
{
// Rising edge
COL1_HIGH;
// set falling edge interrupt
P1IES |= (BIT4);
}
P1IFG &= ~(BIT4);
}
// ROW_2
if(P1IFG & BIT6) {
// Rising or falling edge?
if(P1IES & BIT6)
{
// Falling edge
// If button 2 pressed set COL_1 to low
if(ucButtonPressStatus & BIT2)
{
COL1_LOW;
}
// set rising edge interrupt
P1IES &= ~(BIT6);
}
else
{
// Rising edge
COL1_HIGH;
// set falling edge interrupt
P1IES |= (BIT6);
}
P1IFG &= ~(BIT6);
}
// ROW_3
if(P1IFG & BIT7) {
// Rising or falling edge?
if(P1IES & BIT7)
{
// Falling edge
// If button 3 pressed set COL_1 to low
if(ucButtonPressStatus & BIT3)
{
COL1_LOW;
}
// set rising edge interrupt
P1IES &= ~(BIT7);
}
else
{
// Rising edge
COL1_HIGH;
// set falling edge interrupt
P1IES |= (BIT7);
}
P1IFG &= ~(BIT7);
}
}