我在使用电容触摸按键,但是每当单片机运行到 TI_CAPT_Init_Baseline(&slider); //电容触摸初始化
事就会跳到 这
void TI_CTS_fRO_COMPB_TA1_SW_HAL(const struct Sensor *group,uint16_t *counts)
{
uint8_t i;
uint16_t j;
//** Context Save
// TIMERA0: TA1CTL, TA1CCTL1
// COMPB: CBCTL0, CBCTL1, CBCTL2, CBCTL3
// Ports: CboutDIR, CboutSel
uint16_t contextSaveTA1CTL,contextSaveTA1CCR0;
uint16_t contextSaveCBCTL0,contextSaveCBCTL1;
uint16_t contextSaveCBCTL2,contextSaveCBCTL3;
uint8_t contextSaveCboutDir,contextSaveCboutSel;
contextSaveTA1CTL = TA1CTL;
contextSaveTA1CCR0 = TA1CCR0;
contextSaveCBCTL0 = CBCTL0;
contextSaveCBCTL1 = CBCTL1;
contextSaveCBCTL2 = CBCTL2;
contextSaveCBCTL3 = CBCTL3;
contextSaveCboutDir = *(group->cboutTAxDirRegister);
contextSaveCboutSel = *(group->cboutTAxSelRegister);
//** Setup Measurement timer***************************************************
// connect CBOUT with TA1
*(group->cboutTAxDirRegister) |= (group->cboutTAxBits);
*(group->cboutTAxSelRegister) |= (group->cboutTAxBits);
CBCTL2 = CBREF14+CBREF13 + CBREF02;
// Configure Timer TA1
TA1CCR0 =(group->accumulationCycles);
// Turn on Comparator
CBCTL1 = CBON + CBF; // Turn on comparator with filter
// Vcc to resistor ladder
CBCTL3 |= (group->cbpdBits); // set CPD bits to disable
// I/O buffer
CBCTL2 |= CBRS_1; // Turn on reference
for (i = 0; i<(group->numElements); i++)
{
j=0;
CBCTL0 = CBIMEN + (group->arrayPtr)->inputBits;
//** Setup Gate Timer ********************************************************
// Set duration of sensor measurment
TA1CTL = TASSEL_0+TACLR+MC_1; // TA1CLK, reset, up mode
TA1CTL &= ~TAIFG; // clear ifg
while(!(TA1CTL & TAIFG)) //:'(
{
j++;
} // end accumulation //:'(
counts = j;
//P1SEL &=~BIT4;
}
// End Sequence
//** Context Restore
// TIMERA0: TACTL, TACCTL1
// COMPB: CBCTL0, CBCTL1, CBCTL2, CBCTL3
// Ports: CboutDIR, CboutSel
TA1CTL = contextSaveTA1CTL;
TA1CCR0 = contextSaveTA1CCR0;
CBCTL0 = contextSaveCBCTL0;
CBCTL1 = contextSaveCBCTL1;
CBCTL2 = contextSaveCBCTL2;
CBCTL3 = contextSaveCBCTL3;
*(group->cboutTAxDirRegister) = contextSaveCboutDir;
*(group->cboutTAxSelRegister) = contextSaveCboutSel;
} |