EasyManuals Logo

Texas Instruments MSP430 User Manual

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #406 background imageLoading...
Page #406 background image
406
const struct Element down_element =
{
.inputPxselRegister = (unsigned char *)&P2SEL,
.inputPxsel2Register = (unsigned char *)&P2SEL2,
.inputBits = BIT3,
// When using an abstracted function to measure the element
// the 100*(maxResponse - threshold) < 0xFFFF
// ie maxResponse - threshold < 655
.maxResponse = (100 + 655),
.threshold = 100
};
//*** CAP TOUCH HANDLER *******************************************************/
// This defines the grouping of sensors, the method to measure change in
// capacitance, and the function of the group
const struct Sensor multi_buttons =
{
.halDefinition = RO_PINOSC_TA0_WDTp,
.numElements = 3,
.baseOffset = 0,
// Pointer to elements
.arrayPtr[0] = &up_element, // point to up element
.arrayPtr[1] = &down_element, // point to down element
.arrayPtr[2] = &middle_element, // point to middle element
// Timer Information
.measGateSource= GATE_WDT_ACLK, // 0->SMCLK, 1-> ACLK
.accumulationCycles= WDTp_GATE_64 //64 - Default
};
Similarly, the sensor structure is also modified for these three elements.
The main code is almost identical to the single sensor demo. However, the variable keyPressed is used
to check which element was touched. According to touch on different element states of Launchpad
board LEDs are altered.
keyPressed = (struct Element *)TI_CAPT_Buttons(&multi_buttons);
if(keyPressed)
{
// Up Element
if(keyPressed == &up_element)
{
P1OUT |= BIT0;
}
// Down Element
if(keyPressed == &down_element)
{
P1OUT |= BIT6;
}
// Middle Element
if(keyPressed == &middle_element)
{
P1OUT = 0;
}
}

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals