搜索
bottom↓
回复: 22

发一个STM32L152低功耗片子的串口调试程序,已调通

[复制链接]

出0入0汤圆

发表于 2011-8-27 11:53:09 | 显示全部楼层 |阅读模式
目的:    初步简单调通STM32L低功耗系列片子
实现功能:本次测试使用串口1:USART1-PA9(TX)/PA10(RX),通过串口向电脑发送数据。
硬件平台:将STM32L152CBT6(48PIN)直接替换一块成品板子上的STM32F103CBT6(可能需要注意一下Vlcd管脚)
软件平台:IAR Assembler for ARM  6.10.1.52143 (6.10.1.52143)
          SEGGER J-Flash ARM V4.26a
软件移植:STM32F-->STM32L
点击此处下载 ourdev_671639R0NOR4.zip(文件大小:537K) (原文件名:STM32L152TEST.zip)

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入90汤圆

发表于 2011-8-27 12:08:39 | 显示全部楼层
如果只是用库的话,那么直接用库里的串口例子少许修改就可以了啊!!!!!

出0入0汤圆

发表于 2011-11-8 17:54:03 | 显示全部楼层
回复【1楼】honami520  
-----------------------------------------------------------------------

文件受损了,不能用的,最近在测试STM32L152RBT6的低功耗,测出的电流总是很大总是两三百微安,和手册差的很多,不知道问题出在哪里了,不知道lz有没有相关的例程可以参考一下.(板子上我只焊了单片机及必须的最小系统元件)

出0入0汤圆

 楼主| 发表于 2011-11-9 10:58:00 | 显示全部楼层
回复【2楼】fengye0324  
-----------------------------------------------------------------------

你可以把主频降一下试试,用内部的MSI,并且把Vcore和Vdd也降下来

出0入0汤圆

发表于 2011-11-9 15:34:22 | 显示全部楼层
回复【3楼】adispring  
-----------------------------------------------------------------------

用了MSI了,Vcore也降下来了,VDD也降下来了,还是不行,测出四十多uA,和手册差很多啊,另外,请加一下,这样在STOP模式下,怎么能仿真呢?

出0入0汤圆

发表于 2011-11-9 15:36:26 | 显示全部楼层
/* Includes ------------------------------------------------------------------*/
#include "stm32l1xx.h"


/* Private function prototypes -----------------------------------------------*/
void RCC_Configuration(void);
void GPIO_Configuration(void);
/* Private functions ---------------------------------------------------------*/

/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{

  /* System Clocks Configuration **********************************************/
  RCC_Configuration();
  GPIO_Configuration();
   
#ifdef  VECT_TAB_RAM   
  /* Set the Vector Table base location at 0x20000000 */  
  NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);  
#else  /* VECT_TAB_FLASH  */
  /* Set the Vector Table base location at 0x08000000 */  
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
#endif
   
    NVIC_InitTypeDef  NVIC_InitStructure;
  /* Enable the RTC Wakeup Interrupt */
   NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);
   
   /* RTC Wakeup Interrupt Generation: Clock Source: RTCDiv_16, Wakeup Time Base: 4s */
  RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
  RTC_SetWakeUpCounter(0x1FFF);

  /* Enable the Wakeup Interrupt */
  RTC_ITConfig(RTC_IT_WUT, ENABLE);
   
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, DISABLE);
   
  PWR_UltraLowPowerCmd(ENABLE);   
  PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);   
   
  // RCC_MCOConfig(RCC_MCOSource_LSE, RCC_MCODiv_1);
//
  while (1)
  {
  }
}

/**
  * @brief  Configures the different system clocks.
  * @param  None
  * @retval None
  */
void RCC_Configuration(void)
{
  /* Enable The PWR Clock */
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

  /* Allow access to RTC */
  PWR_RTCAccessCmd(ENABLE);

  /*!< LSE Enable */
  RCC_LSEConfig(RCC_LSE_ON);

  /*!< Wait till LSE is ready */
  while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
  {}

  /*!< LCD Clock Source Selection */
  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
}

/**
  * @brief  Configures the different GPIO ports.
  * @param  None
  * @retval None
  */
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  ///* Enable HSI */
  //RCC_HSICmd(ENABLE);

  /* Enable the GPIOA peripheral */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

  /* Output the system clock on MCO pin (PA.08) */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_400KHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  GPIO_Init(GPIOD, &GPIO_InitStructure);
}

#ifdef  USE_FULL_ASSERT

/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while (1)
  {
  }
}
#endif

/**
  * @}
  */

/**
  * @}
  */

/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/


以下是RTC中断
void RTC_WKUP_IRQHandler(void)
{
  if(RTC_GetITStatus(RTC_IT_WUT) != RESET)
  {
   

  /* Enable HSI */
  RCC_HSICmd(ENABLE);

  /* Enable the GPIOA peripheral */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

  /* Output the system clock on MCO pin (PA.08) */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
    RCC_MCOConfig(RCC_MCOSource_LSE, RCC_MCODiv_1);
     PWR_UltraLowPowerCmd(ENABLE);   
     PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);   
     RTC_ClearITPendingBit(RTC_IT_WUT);
      
  }  
}

运行起来PA8测不出输出频率,电流表测到的电流为48uA,
注:电路上只焊接了单片机及其必要的元件(电阻,电容,晶振),外加的外围器件都没焊接

出0入0汤圆

 楼主| 发表于 2011-11-10 09:52:15 | 显示全部楼层
回复【4楼】fengye0324  
-----------------------------------------------------------------------

估计你用的是在FLASH里跑的程序吧,手册上说FLASH跑程序在运行状态下是65微安/MHZ的。另外焊掉外部的晶振,用内部的LSI做RTC时钟源试试,MSI


低功耗模式(睡眠和停止模式)下的调试不能用普通模式下的调试手段进行,具体调试方法如下(引自参考手册),(本人未测过:)

低功耗模式的调试支持
使用WFI和WFE可以进入低功耗模式。
MCU支持多种低功耗模式,分别可以关闭CPU时钟,或降低CPU的能耗。
内核不允许在调试期间关闭FCLK或HCLK。这些时钟对于调试操作是必要的,因此在调试期
间,它们必须工作。MCU使用一种特殊的方式,允许用户在低功耗模式下调试代码。
为实现这一功能,调试器必须先设置一些配置寄存器来改变低功耗模式的特性。
● 在睡眠模式下,调试器必须先置位DBGMCU_CR寄存器的DBG_SLEEP位。这将为HCLK
提供与FCLK(由代码配置的系统时钟)相同的时钟。
● 在停止模式下,调试器必须先置位DBG_STOP位。这将激活内部RC振荡器,在停止模式下
为FCLK和HCLK提供时钟。

Debug support for low-power modes
To enter low-power mode, the instruction WFI or WFE must be executed.
The MCU implements several low-power modes which can either deactivate the CPU clock
or reduce the power of the CPU.
The core does not allow FCLK or HCLK to be turned off during a debug session. As these
are required for the debugger connection, during a debug, they must remain active. The
MCU integrates special means to allow the user to debug software in low-power modes.
For this, the debugger host must first set some debug configuration registers to change the
low-power mode behavior:
● In Sleep mode, DBG_SLEEP bit of DBGMCU_CR register must be previously set by
the debugger. This will feed HCLK with the same clock that is provided to FCLK
(system clock previously configured by the software).
● In Stop mode, the bit DBG_STOP must be previously set by the debugger. This will
enable the internal RC oscillator clock to feed FCLK and HCLK in STOP mode.

出0入0汤圆

发表于 2011-11-10 13:08:40 | 显示全部楼层
恭喜LZ

出0入0汤圆

发表于 2012-1-18 10:09:22 | 显示全部楼层
mark

出0入0汤圆

发表于 2012-1-18 10:09:41 | 显示全部楼层
mark

出0入0汤圆

发表于 2012-9-11 09:38:47 | 显示全部楼层
mark


出0入0汤圆

发表于 2013-3-21 21:29:21 | 显示全部楼层
mark ,一下

出0入0汤圆

发表于 2013-3-21 21:31:13 | 显示全部楼层
mark,,,ST的芯片果然是PIN2PIN

出0入0汤圆

发表于 2013-3-22 08:51:29 | 显示全部楼层
mark。。。

出0入0汤圆

发表于 2013-3-22 08:51:48 | 显示全部楼层
好东西就要多看看

出0入0汤圆

发表于 2013-6-24 12:32:56 | 显示全部楼层
学习了!!!

出0入0汤圆

发表于 2013-7-1 23:02:20 | 显示全部楼层
学习了~~~!!!

出0入0汤圆

发表于 2013-8-2 10:10:00 | 显示全部楼层
请问楼主有没有历程,我现在也在搞STM32L152低功耗,可是现在我连程序也下不进去,是不是和STM32F103所使用的工程不一样呢?或者是那里的配置有所差别!?

出0入0汤圆

发表于 2013-8-2 11:32:42 | 显示全部楼层
程序下载下来好像不能用,这是为什么呢?

出0入0汤圆

发表于 2013-10-14 16:31:26 | 显示全部楼层
楼上  请问你调试的怎么样了 这个低功耗的片子  adc和dma 很难的调啊

出0入0汤圆

发表于 2014-1-15 18:02:33 | 显示全部楼层
mark~表示STM32L的库和STM32F1的库里面的GPIO设置差挺多的,想问一下RX对应的GPIO应该怎么设置才好呢?

出0入0汤圆

发表于 2014-4-28 14:12:14 | 显示全部楼层
mark.最近用STM32L系列,不知道为什么外部晶振不启振,下来研究下

出0入0汤圆

发表于 2015-3-26 16:48:22 | 显示全部楼层
已阅,支持下
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-12 20:01

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表