不好意思了各位,论坛活动我在XX在打卡赠送的开发板收到已经很久时间了,一直没有进行评测,为什么呢,主要是没想到用它进行什么测试,感觉它的功能这么强大,不能埋没了呀(同时手上有一个MP157的板子,想要测试视频和图形这块,要做一个MIPI转RGB的转接板才能测试,也在考虑要测些什么好),眼看就要到月底了,考虑到现在的应用环境基本都是基于锂电池供电的,那么大家对于低功耗肯定是有所关注的,所以这次就先测量一下它的功耗情况,看看280MHz下的功耗和休眠后的功耗各是多少?
废话不多说,一如概往,要进行测试,先下载开发板的CUBE评估软件,大家可以在https://www.stmcu.com.cn/Designresource/design_resource_detail/file/578880/lang/EN/token/e32661634bf756291653a9fd984eddd3下载到,话说这个软件包真大,目前的版本是V1.7.0,大小有931M,超出想像太多,那么到底是怎么回事呢?
打开软件包,我们看看支持哪些芯片?
原来这次ST将所有H7芯片的DEMO代码全部打包在一起了。
好了,我们选择NUCLEO-H7A3ZI-Q文件夹下的代码打开它,嗯,这次ST不错,分别提供了HAl库和LL库的DEMO,这里我选择HAl库下的模板,选择*:\STM32Cube_FW_H7_V1.7.0\Projects\NUCLEO-H7A3ZI-Q\Examples\PWR\PWR_STOP2_RTC,利用RTC唤醒停机模式的模板。
我们看一下代码:
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] Main program
* @param None
* @retval None
*/
int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable the CPU Cache */
CPU_CACHE_Enable();
/* STM32H7xx HAL library initialization:
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for example or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();
/* Configure LED1, and LED3 */
BSP_LED_Init(LED1);
BSP_LED_Init(LED3);
/* Configure the system clock to 280 MHz */
SystemClock_Config();
/* Configure the RTC */
RTC_Config();
while (1)
{
fail_number = 0;
/* Fill AXISRAM1 Memory */
for (int count = 0; count < (CD_AXISRAM1_SIZE / CD_AXI_DATAWIDTH); count++)
{
*(uint64_t *)(CD_AXISRAM1_BASE + (count * CD_AXI_DATAWIDTH)) = Data64;
}
/* Insert 5 second delay */
HAL_Delay(5000);
/* Enable GPIOs clock */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
/* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */
/* Note: Debug using ST-Link is not possible during the execution of this */
/* example because communication between ST-link and the device */
/* under test is done through UART. All GPIO pins are disabled (set */
/* to analog input mode) including UART I/O pins. */
GPIO_InitStructure.Pin = GPIO_PIN_All;
GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
GPIO_InitStructure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOF, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);
/* Disable GPIOs clock */
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOE_CLK_DISABLE();
__HAL_RCC_GPIOF_CLK_DISABLE();
__HAL_RCC_GPIOG_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
/* Disable all used wakeup source */
HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
/* Re-enable wakeup source */
/* ## Setting the Wake up time ############################################*/
/* RTC Wakeup Interrupt Generation:
the wake-up counter is set to its maximum value to yield the longest
stop time to let the current reach its lowest operating point.
The maximum value is 0xFFFF, corresponding to about 33 sec. when
RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16 */
/* Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSI))
Wakeup Time = Wakeup Time Base * WakeUpCounter
= (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSI)) * WakeUpCounter
==> WakeUpCounter = Wakeup Time / Wakeup Time Base */
/* To configure the wake up timer to 33s the WakeUpCounter is set to 0xFFFF:
Wakeup Time Base = 16 /(~32 kHz RC) = ~0.5 ms
Wakeup Time = 0.5 ms * WakeUpCounter
Therefore, with wake-up counter = 0xFFFF = 65,535
Wakeup Time = 0.5 ms * 65,535 = ~ 33 sec. */
HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0xFFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
/* Enable AXI MEMORY block shut-off in DStop2 modes */
HAL_PWREx_EnableMemoryShutOff(PWR_RAM1_AXI_MEMORY_BLOCK);
/* Clear STOP flag */
__HAL_PWR_CLEAR_FLAG(PWR_CPU_FLAGS);
/* Enter CD to DStop2 mode and SRD to DStop mode */
if(__HAL_PWR_GET_FLAG(PWR_FLAG_STOP) == RESET)
{
/* Turn LED1 OFF */
BSP_LED_Off(LED1);
/* Enter the system to STOP mode with main domain in DSTOP2 */
HAL_PWREx_EnterSTOP2Mode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI);
}
/* ... STOP2 mode ... */
if (HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle) != HAL_OK)
{
Error_Handler();
}
/* Configure system clock after wake-up from STOP: enable HSE, PLL and select
PLL as system clock source (HSE and PLL are disabled in STOP mode) */
SYSCLKConfig_STOP();
/* Check AXISRAM1 content */
for (int count = 0; count < (CD_AXISRAM1_SIZE / CD_AXI_DATAWIDTH); count++)
{
if (*(uint64_t *)(CD_AXISRAM1_BASE + (count * CD_AXI_DATAWIDTH)) != Data64)
{
fail_number++;
}
}
/* Check fail number */
if (fail_number == 0U)
{
Error_Handler();
}
/* Re-configure and turn on LED1 */
BSP_LED_Init(LED1 );
BSP_LED_On(LED1 );
}
}
在上面的代码中不知道各位有没有注意到一点,在进入低功耗前,IO口全部初始化为浮空输入时,一定先要把IO的时钟打开,再初始化端口寄存器,初始化完成后,再把IO时钟关闭。
|