Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef RO_PINOSC_TA0
- /***************************************************************************//**
- * @brief RO method capactiance measurement using PinOsc IO, and TimerA0
- *
- * Schematic Description:
- *
- * \n element-----+->Px.y
- *
- * \n The measurement window is accumulation_cycles/ACLK. The ACLK is
- * used to generate a capture event via the internal connection CCIOB.
- * The counts within the TA0R that have accumulated during the
- * measurement window represents the capacitance of the element.
- *
- * @param group Pointer to the structure describing the Sensor to be measured
- * @param counts Pointer to where the measurements are to be written
- * @return none
- ******************************************************************************/
- extern uint8_t CCR0_interrupted;
- inline void my_delay(unsigned int d) { // Delays d instruction cycles (d µs @ 1MHz)
- for(; d > 0 ; d--) {
- __no_operation();
- }
- }
- void TI_CTS_RO_PINOSC_TA0_HAL(const struct Sensor *group,uint16_t *counts)
- {
- uint8_t i;
- uint16_t j;
- //** Context Save
- // TIMERA0: TA0CTL, TA0CCTL0
- // Ports: PxSEL, PxSEL2
- uint16_t contextSaveTA0CTL,contextSaveTA0CCTL0,contextSaveTA0CCR0;
- uint8_t contextSaveSel,contextSaveSel2;
- contextSaveTA0CTL = TA0CTL;
- contextSaveTA0CCTL0 = TA0CCTL0;
- contextSaveTA0CCR0 = TA0CCR0;
- //** Setup Measurement timer***************************************************
- // Choices are TA0,TA1,TB0,TB1,TD0,TD1 these choices are pushed up into the
- // capacitive touch layer.
- // Configure and Start Timer
- TA0CTL = TASSEL_3+MC_2; // INCLK, continuous up mode
- for (i =0; i< (group->numElements); i++)
- {
- // Context Save
- contextSaveSel = *((group->arrayPtr[i])->inputPxselRegister);
- contextSaveSel2 = *((group->arrayPtr[i])->inputPxsel2Register);
- // Configure Ports for relaxation oscillator
- j = (group->accumulationCycles);
- *((group->arrayPtr[i])->inputPxselRegister) &= ~((group->arrayPtr[i])->inputBits);
- *((group->arrayPtr[i])->inputPxsel2Register) |= ((group->arrayPtr[i])->inputBits);
- CCR0_interrupted = 0;
- TA0CCTL0 = CM_3+CCIS_1+CAP+CCIE; // Pos&Neg,ACLK (CCI0B),Cap & interrupt
- // Put the MSP430 into LPM0
- while(!CCR0_interrupted) {
- P1OUT &= ~BIT6;
- _BIS_SR(LPM0_bits+GIE);
- }
- TA0CTL |= TACLR; // Clear Timer_A TAR
- while(j--)
- {
- CCR0_interrupted = 0;
- TA0CCTL0 = CM_3+CCIS_1+CAP+CCIE; // Pos&Neg, ACLK (CCI0B), Cap & interrupt
- //P1OUT |= BIT0;
- //* Put the MSP430 into LPM0
- while(!CCR0_interrupted) {
- P1OUT &= ~BIT6;
- _BIS_SR(LPM0_bits+GIE);
- }
- //*/
- //P1OUT &= ~BIT0;
- }
- counts[i] = TA0CCR0; // Save result
- TA0CTL = TASSEL_3+MC_2;
- // Context Restore
- *((group->arrayPtr[i])->inputPxselRegister) = contextSaveSel;
- *((group->arrayPtr[i])->inputPxsel2Register) = contextSaveSel2;
- }
- // End Sequence
- // Context Restore
- TA0CTL = contextSaveTA0CTL;
- TA0CCTL0 = contextSaveTA0CCTL0;
- TA0CCR0 = contextSaveTA0CCR0;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement