This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP432E401Y:调试会话中的定时器行为与不同。 非调试会话

Guru**** 2560390 points
Other Parts Discussed in Thread: MSP432E401Y

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/905051/msp432e401y-different-timer-behavior-in-debug-session-versus-non-debug-session

器件型号:MSP432E401Y

您好!

我们看到与 MSP432E4微控制器的边沿计数计时器功能相关的非常奇怪的行为。 当我们使用 Code Composer Studio 中的调试会话对微控制器进行编程时、计数的边沿数是正确的(在200ms 时间窗口内、大约44000个边沿)。 但是、一旦我们离开调试会话(在 CCS 中单击"终止"或对 MCU 进行下电上电)、计数的边沿数就不正确、大约比我们预期的要少35倍(大约1200个边沿计数)。 我们可以确认计时器引脚的输入信号没有变化。 当不在调试会话中时、所有其它功能都存在。 以下是软件工程师设置并告知我在该帖子中包含的相关功能。 在这个项目的硬件方面、请告诉我是否有一些我可以与软件工程师澄清的东西并添加到这个帖子中。

时钟设置和计时器设置功能如下所示。 采样周期是我们想要对边沿进行计数而不发生溢出的时间窗口、在本例中为200ms:

HVBoard:::ClockSetUp()

   uint32_t SamplePeriod;

 

   SamplePeriod = 200000/Clock_tickPeriod;// 200ms

 

   Clock_Params_init (clkParams);

   clkParams.period = SamplePeriod;

   clkParams.startFlag = true;

 

   /*构造周期性时钟实例*/

   Clock_con构(&clk0Struct,(Clock_Functr) LevelSensingCounter、SamplePeriod、&clkParams);

 

HVBoard:::LevelSensingTimerSetUp()

   /*启用到 GPIO 端口 M 的时钟并等待它准备就绪*/

   MAP_SysCtlPeripheralEnable (SYSCTL_Periph_GPIOM);

   while (!(SysCtlPeripheralReady (SYSCTL_Periph_GPIOM)));

   //*将 GPIO PM6配置为计时器5 CCP0引脚(边沿计数输入引脚)*/

   MAP_GPIOPinConfigure (GPIO_PM6_T5CCP0);

   MAP_GPIOPinTypeTimer (GPIO_PORTM_BASE、GPIO_PIN_6);

   /*启用计时器5 */

   MAP_SysCtlPeripheralEnable (SYSCTL_Periph_TIMER5);

   while (!(SysCtlPeripheralReady (SYSCTL_Periph_TIMER5)));

   /*将计时器5配置为在边沿计数模式下工作*/

   MAP_TimerConfigure (TIMER5_base、TIMER_CFG_A_CAP_COUNT);

   /*正边数*/

   MAP_TimerControlEvent (TIMER5_base、TIMER_A、TIMER_EVENT_POS_EDGE);

   /*加载计时器5的值以进行计数*/

   MAP_TimerLoadSet (TIMER5_base、TIMER_A、LS_MAX_COUNT);

 

void LevelSensingCounter()

   MAP_TimerDisable (TIMER5_base、TIMER_A);

   LevelSensingCount = MAP_TimerValueGet (TIMER5_base、TIMER_A);

   MAP_TimerLoadSet (TIMER5_base、TIMER_A、LS_MAX_COUNT);

   MAP_TimerEnable (TIMER5_base、TIMER_A);

一旦 Clock_construct()被创建和启用(clkParams.startFlag = true;)、它将在每次计数 SamplePeriod 后调用上述函数

请告诉我们问题可能是什么。 谢谢!

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我们发现导致问题的原因! 有一个使用 ClockP_usleep()的心跳 LED 函数。 当 LED 稳定时没有问题,但是当使用 ClockP_usleep()使 LED 闪烁时,我们会看到错误的读数。 下面是功能和设置。 这是软件工程师设置线程的文件:

    静态 Tf_thread_struct tfUSBRxProcessThread;
    静态 Tf_uint8 tfUSBRxProcessThreadStack[0x800];
    
    静态 Tf_thread_struct tfUSBTxProcessThread;
    静态 Tf_uint8 tfUSBTxProcessThreadStack[0x200];
    
    静态 Tf_thread_struct hvBoardStatusThread;
    静态 Tf_uint8 hvBoardStatusThreadStack[MAIN_HVBOARD_STATUS_STACK_SIZE];
    
    静态 Tf_thread_struct hvBoardCanaryLEDProcessThread;
    静态 Tf_uint8 hvBoardCanaryLEDProcessThreadStack[0x200]; 

    void hvBoardCanaryLEDProcess (void * arg0、void * arg1)
    {
    while (真)
    {
    GPIO_SET (TestLEDPin);
    // ClockP_usleep (900000);
    // GPIO_Reset (TestLEDPin);
    // ClockP_usleep (200000);
    // GPIO_SET (TestLEDPin);
    // ClockP_usleep (200000);
    // GPIO_Reset (TestLEDPin);
    // ClockP_usleep (200000);
    // GPIO_SET (TestLEDPin);
    // ClockP_usleep (200000);
    // GPIO_Reset (TestLEDPin);
    // ClockP_usleep (900000);
    }
    } 

    void CreateThreads (void)
    {
    
    tfUSBRxProcessThread.threadStack = tfUSBRxProcessThreadStack;
    tfUSBRxProcessThread.threadStackSize = sizeof (tfUSBRxProcessThreadStack);
    tfUSBRxProcessThread.threadPriority = USB_Rx_Thread_Priority;
    TfOsThreadCreate (_tfUSBRxProcessThread、
    USBRxProcess、
    nullptr、
    nullptr、
    "USB 接收线程");
    
    tfUSBTxProcessThread.threadStack = tfUSBTxProcessThreadStack;
    tfUSBTxProcessThread.threadStackSize = sizeof (tfUSBTxProcessThreadStack);
    tfUSBTxProcessThread.threadPriority = USB_TX_Thread_Priority;
    TfOsThreadCreate (_tfUSBTxProcessThread、
    USBTxProcess、
    nullptr、
    nullptr、
    "USB TX 线程");
    
    hvBoardStatusThread.threadStack = hvBoardStatusThreadStack;
    hvBoardStatusThread.threadStackSize = sizeof (hvBoardStatusThreadStack);
    hvBoardStatusThread.threadPriority = HVBoard_Status_Thread_Priority;
    TfOsThreadCreate (.hvBoardStatusThread、
    HVBoardStatus、
    nullptr、
    nullptr、
    "HV 电路板状态线程");
    
    hvBoardCanaryLEDProcessThread.threadStack = hvBoardCanaryLEDProcessThreadStack;
    hvBoardCanaryLEDProcessThread.threadStackSize = sizeof (hvBoardCanaryLEDProcessThreadStack);
    hvBoardCanaryLEDProcessThread.threadPriority = HVBoard_CanaryLED_Thread_Priority;
    TfOsThreadCreate (&hvBoardCanaryLEDProcessThread、
    HvBoardCanaryLEDProcess、
    nullptr、
    nullptr、
    "HV Board Canary LED Thread");
    } 

    可能会出现优先级问题?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我想您的发展方向是正确的、恭喜

       Johann