TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP432E401Y: MSP432P401R 关于例程timer_a_continuous_vlo_period_capture的一些问题

Part Number:MSP432E401Y

我利用 tool – graph – single time  看timerAcaptureValues的值

      

//////////////////////////////////////////////////////////////////////////////// 

/* –COPYRIGHT–,BSD
* Copyright (c) 2017, 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–*/
/*******************************************************************************
* MSP432 Timer_A – VLO Period Capture
*
* Description: Capture a number of periods of the VLO clock and store them in
* an array. When the set number of periods is captured the program is trapped
* and the LED on P1.0 is toggled. At this point halt the program execution read
* out the values using the debugger.
* ACLK = VLOCLK = 14kHz (typ.), MCLK = SMCLK = default DCO = 3MHz
*
* MSP432P401
* ——————
* /|\| |
* | | |
* –|RST P1.0 |—> P1.0 LED
* | P2.4 |— TA0.1
* | | |
* | P4.2 |— ACLK
* | |
*******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <stdint.h>
#define NUMBER_TIMER_CAPTURES 20

/* Timer_A Continuous Mode Configuration Parameter */
const Timer_A_ContinuousModeConfig continuousModeConfig =
{
TIMER_A_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
TIMER_A_CLOCKSOURCE_DIVIDER_1, // SMCLK/1 = 3MHz
TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer ISR
TIMER_A_SKIP_CLEAR // Skup Clear Counter
};

/* Timer_A Capture Mode Configuration Parameter */
const Timer_A_CaptureModeConfig captureModeConfig =
{
TIMER_A_CAPTURECOMPARE_REGISTER_1, // CC Register 2
TIMER_A_CAPTUREMODE_RISING_EDGE, // Rising Edge
TIMER_A_CAPTURE_INPUTSELECT_CCIxB, // CCIxB Input Select
TIMER_A_CAPTURE_SYNCHRONOUS, // Synchronized Capture
TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE, // Enable interrupt
TIMER_A_OUTPUTMODE_OUTBITVALUE // Output bit value
};

/* Statics */
static volatile uint_fast16_t timerAcaptureValues[NUMBER_TIMER_CAPTURES];
static volatile uint32_t timerAcapturePointer = 0;

int main(void)
{
/* Stop watchdog timer */
MAP_WDT_A_holdTimer();

/* Configuring P1.0 as output */
MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);

/* Configuring P2.4 as peripheral input for capture and P4.2 for ACLK
* output */
MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P4, GPIO_PIN2,
GPIO_PRIMARY_MODULE_FUNCTION);
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2, GPIO_PIN4,
GPIO_PRIMARY_MODULE_FUNCTION);

/* Setting ACLK = VLO = 14kHz */
MAP_CS_initClockSignal(CS_ACLK, CS_VLOCLK_SELECT, CS_CLOCK_DIVIDER_1);

/* Configuring Capture Mode */
MAP_Timer_A_initCapture(TIMER_A0_BASE, &captureModeConfig);

/* Configuring Continuous Mode */
MAP_Timer_A_configureContinuousMode(TIMER_A0_BASE, &continuousModeConfig);

/* Enabling interrupts and going to sleep */
MAP_Interrupt_enableSleepOnIsrExit();
MAP_Interrupt_enableInterrupt(INT_TA0_N);
MAP_Interrupt_enableMaster();

/* Starting the Timer_A0 in continuous mode */
MAP_Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_CONTINUOUS_MODE);

MAP_PCM_gotoLPM0();

}

//******************************************************************************
//
//This is the TIMERA interrupt vector service routine.
//
//******************************************************************************
void TA0_N_IRQHandler(void)
{
uint32_t jj;

timerAcaptureValues[timerAcapturePointer++] =
MAP_Timer_A_getCaptureCompareCount(TIMER_A0_BASE,
TIMER_A_CAPTURECOMPARE_REGISTER_1);

if (timerAcapturePointer >= NUMBER_TIMER_CAPTURES)
{
while (1)
{
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
for(jj=0;jj<10000;jj++);
}
}
}

/////////////////////////////////////

仅仅在上升沿捕获  14Khz的话一个脉冲是 7.8571428571428571428571428571429e-4s   3Mhz 一个脉冲是3.3333333333333333333333333333333e-7s 二者相除的话不应该是2,357个脉冲个数吗

而且为什么有一段横线

Yale Li:

您好,不好意思回复晚了。

我想问一下是每一次都出现这样的结果吗?

,

?? ?:

我测的每一次几乎都是这样的

,

Yale Li:

您好,从代码来看,timerAcaptureValues的值是每次TimerA捕捉到ACLK的上升沿时,TAR寄存器的计数值。

我建议您加入断点,运行单步调试,单独来看timerAcaptureValues的值的变化情况以及TAR寄存器、CCR1寄存器的值的变化情况。

赞(0)
未经允许不得转载:TI中文支持网 » MSP432E401Y: MSP432P401R 关于例程timer_a_continuous_vlo_period_capture的一些问题
分享到: 更多 (0)