我在 NUCLEO_L432KC 和 MBed CLI 上使用 MBed OS 来编译、刷写和测试。使用 OpenOCD 和 gdb 进行调试。MBed 有自己的 GreenTea 测试自动化工具,用于在嵌入式硬件上进行单元测试,它使用 utest 和 Unity 测试框架。
当我使用 GreenTea 对这个函数进行单元测试时:
float Piano::midiNumToFrequency(uint8_t m)
{
float exp = (m - 69.0f) / 12.0f;
return pow(2, exp);
}
我收到 DeepSleepLock 下溢错误:
[1589410046.26][CONN][RXD] ++ MbedOS 错误信息 ++ [1589410046.30][CONN][RXD] 错误状态:0x80040124 代码:292 模块:4 [1589410046.35][CONN][RXD] 错误消息:DeepSleepLock 下溢( < 0) [1589410046.37][CONN][RXD] 位置:0x8003B09 [1589410046.40][CONN][RXD] 文件:mbed_power_mgmt.c+197 [1589410046.43][CONN][RXD] 错误值:0xFFFF [1589410046.53][CONN] [RXD] 当前线程:主 Id:0x20001200 条目:0x80044A7 StackSize:0x1000 StackMem:0x20001C18 SP:0x2000FF04 [1589410046.62][CONN][RXD] 更多信息,请访问: https ://mbed.com/s/error?error =0x80040124&tgt=NUCLEO_L432KC [1589410046.64][CONN][RXD] – MbedOS 错误信息 –</p>
然而,当我将功能更改为此:
float Piano::midiNumToFrequency(uint8_t m)
{
float exp = (m - 69.0f);
return pow(2, exp);
}
它可以正常工作并且测试良好。
MBed在这里有一个错误状态解码器,上面写着
使用报告的“位置”来找出导致错误的位置的地址,或者尝试构建一个启用了 MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 配置的非发布版本,以捕获此错误源自的文件名和行号。
当我启用 MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 时,它说位置在 mbed_power_mgmt.c 第 197 行,这是函数:
/** Send the microcontroller to sleep
*
* @note This function can be a noop if not implemented by the platform.
* @note This function will be a noop in debug mode (debug build profile when MBED_DEBUG is defined).
* @note This function will be a noop if the following conditions are met:
* - The RTOS is present
* - The processor turn off the Systick clock during sleep
* - The target does not implement tickless mode
*
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
*
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
*
* @note
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
* able to access the LocalFileSystem
*/
static inline void sleep(void)
{
#if DEVICE_SLEEP
#if (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_SYSTICK_CLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS)
sleep_manager_sleep_auto();
#endif /* (MBED_CONF_RTOS_PRESENT == 0) || (DEVICE_SYSTICK_CLK_OFF_DURING_SLEEP == 0) || defined(MBED_TICKLESS) */
#endif /* DEVICE_SLEEP */
}
任何想法为什么会发生这种情况或如何进一步排除故障?