Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

430BOOST-SENSE1

$
0
0

Hi, everyone!

I want to use this amazing booster pack for msp430g2452, so I`ve downloaded the user experience example and tried to change it a little bit.

But i am experiencing some interesting issue. When I hold the middle button, the program can`t recognize that.

Please find the program below. It would be great, if you can tell me, what I am doing wrong.

#include "CTS_Layer.h"
#include "uart.h"


#define P10 0x01 // replaces all instances of the text "P10" with "0x01" prior to compiling
#define P11 0x02 // replaces all instances of the text "P11" with "0x02" prior to compiling
#define P12 0x04 // replaces all instances of the text "P12" with "0x04" prior to compiling
#define P13 0x08 // replaces all instances of the text "P13" with "0x08" prior to compiling
#define P14 0x10 // replaces all instances of the text "P14" with "0x10" prior to compiling
#define P15 0x20 // replaces all instances of the text "P15" with "0x20" prior to compiling
#define P16 0x40 // replaces all instances of the text "P16" with "0x40" prior to compiling
#define P17 0x80 // replaces all instances of the text "P17" with "0x80" prior to compiling

// Functions
void LmotorFWD(void); // enables the left motor in the forward direction
void LmotorREV(void); // enables the left motor in the reverse direction
void LmotorOFF(void); // disables the left motor
void RmotorFWD(void); // enables the right motor in the forward direction
void RmotorREV(void); // enables the right motor in the reverse direction
void RmotorOFF(void); // disables the right motor


#define MIDDLE_BUTTON_CODE 0x80
#define INVALID_GESTURE 0xFD
#define GESTURE_START 0xFC
#define GESTURE_STOP 0xFB
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE 2
#define GESTURE_POSITION_OFFSET 0x20
#define WHEEL_POSITION_OFFSET 0x30

#define WHEEL_TOUCH_DELAY 12 //Delay between re-sendings of touches
#define MAX_IDLE_TIME 200
#define PROXIMITY_THRESHOLD 60

unsigned int wheel_position=ILLEGAL_SLIDER_WHEEL_POSITION, last_wheel_position=ILLEGAL_SLIDER_WHEEL_POSITION;
unsigned int deltaCnts[1];
unsigned int prox_raw_Cnts;

unsigned int centerButtonTouched = 0;

#define MASK7 BIT4
#define MASK6 BIT5
#define MASK5 BIT6
#define MASK4 BIT7

#define MASK3 (BIT3+BIT4+BIT5+BIT6)
#define MASK2 (BIT3+BIT4+BIT5+BIT7)
#define MASK1 (BIT3+BIT4+BIT6+BIT7)
#define MASK0 (BIT3+BIT5+BIT6+BIT7)

const unsigned char LedWheelPosition[16] =
{
MASK0, MASK0, MASK0 & MASK1, MASK1,
MASK1 & MASK2, MASK2, MASK2 & MASK3, MASK3,
MASK4, MASK4, MASK4 | MASK5, MASK5,
MASK5 | MASK6, MASK6, MASK6 | MASK7, MASK7
};
const unsigned char startSequence[8] =
{
MASK0,
MASK1,
MASK2,
MASK3,
MASK4,
MASK5,
MASK6,
MASK7
};
/*----------------- LED definition------------------------------*/

void InitLaunchPadCore(void)

{
BCSCTL1 |= DIVA_0; // ACLK/(0:1,1:2,2:4,3:8)
BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO

// Port init

P2SEL = 0x00; // No XTAL
P2DIR |= (BIT0+BIT4+BIT2+BIT3+BIT1+BIT5);
P2OUT &= ~(BIT0+BIT4+BIT2+BIT3+BIT1+BIT5);
}



/* ----------------MeasureCapBaseLine--------------------------------------
* Re-measure the baseline capacitance of the wheel elements & the center
* button. To be called after each wake up event.
* ------------------------------------------------------------------------*/
void MeasureCapBaseLine(void)
{
//P1OUT = BIT0;
/* Set DCO to 8MHz */
/* SMCLK = 8MHz/8 = 1MHz */
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
BCSCTL2 |= DIVS_3;

TI_CAPT_Init_Baseline(&middle_button);
TI_CAPT_Update_Baseline(&middle_button,2);
}

/* ----------------CapTouchActiveMode----------------------------------------------
* Determine immediate gesture based on current & previous wheel position
*
* -------------------------------------------------------------------------------*/
void CapTouchActiveMode()
{
/* Set DCO to 8MHz */
/* SMCLK = 8MHz/8 = 1MHz */
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
BCSCTL2 |= DIVS_3;


TACCTL0 &= ~CCIE;
if(TI_CAPT_Button(&middle_button))
{ /* Middle button was touched */
LmotorFWD();
}
}


void main(void)
{

WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer

P1DIR |= P11; // Sets P1.1 as output
P1DIR |= P12; // Sets P1.2 as output
InitLaunchPadCore();

/* Set DCO to 1MHz */
/* Set SMCLK to 1MHz / 8 = 125kHz */
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
BCSCTL2 |= DIVS_3;


LmotorOFF(); // Start with Left Motor OFF


/* Establish baseline for the proximity sensor */
TI_CAPT_Init_Baseline(&proximity_sensor);
TI_CAPT_Update_Baseline(&proximity_sensor,5);

//MeasureCapBaseLine();
while (1)
{
MeasureCapBaseLine();
CapTouchActiveMode();
}
}


// Functions
void LmotorFWD(void)
{
P1OUT &= ~P12; // Turns off P1.2
P1OUT |= P11; // Turns on P1.1
}

void LmotorREV(void)
{
P1OUT &= ~P11; // Turns off P1.1
P1OUT |= P12; // Turns on P1.2
}

void LmotorOFF(void)
{
P1OUT &= ~P11; // Turns off P1.1
P1OUT &= ~P12; // Turns off P1.2
}


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>