[PSOC™] PSoC™ 6 设备配置LVD 模块

[复制链接]
585|0
 楼主| IFX_OwenSu 发表于 2023-9-27 13:53 | 显示全部楼层 |阅读模式
低压检测(LVD)模块用于检测低电压和断电。当供电电池电压低于内部参考电压时,触发LVD中断。使用该中断可实现:在断电前将关键数据写入flash、转储日志、触发外部电路等功能。
Note:
  • 只有实际供电电压低于阈值时,才会触发中断。初始供电电压低于阈值时,不触发中断。
  • LVD电路可在Active模式、低功耗(LP)模式、超低功耗(ULP)模式下正常运行。如果需要在深度睡眠下使用LVD,则需配置deep sleep wake-up source,定期从深度睡眠模式中唤醒设备,确保在Active/LPACTIVE模式下运行LVD电路。
  • 系统初始化阶段有可能会收到错误的LVD中断。系统启动,完成LVD模块配置的20µs 后自动屏蔽该错误中断。
  • 系统进入深度睡眠模式时,如果设置了下降沿触发,或上升沿触发,或两者兼而有之,可能也会收到错误的LVD中断。要解决这个问题,可以在进入深度睡眠模式前禁用该触发设置,退出深度睡眠模式后重新启用触发设置。
LVD驱动(PSoC™ 6 PDL API 参考指南章节之一)文档中提供了管理LVD模块的一系列API

下列为配置LVD模块的节选代码,适用于:
  • PSoC™ 6 设备。
  • 电压阈值设为2.7v,当供电电池电压低于或高于阈值时,产生中断。

  1. /* LVD interrupt configuration */
  2. const cy_stc_sysint_t LVD_interrupt_cfg =
  3. {
  4.     .intrsrc=srss_interrupt_IRQn,
  5.     .intrPriority = LVD_INTERRUPT_PRIORITY
  6. };

  7. /*******************************************************************************
  8. * Function Name: LVD_Init
  9. ********************************************************************************
  10. * Summary:
  11. *  This function initializes and enables the LVD block by:
  12. *    1. Setting the LVD threshold.
  13. *    2. Setting the LVD Interrupt Configuration
  14. *    3. Initializing and enabling the LVD interrupt
  15. *
  16. *******************************************************************************/
  17. void LVD_Init()
  18. {
  19.     /* Disable LVD interrupts */
  20.     Cy_LVD_ClearInterruptMask();

  21.     /* Set the threshold value for monitoring the VDDD voltage */
  22.     Cy_LVD_SetThreshold(CY_LVD_THRESHOLD_2_7_V);

  23.     /* Set configuration for LVD interrupt */
  24.     Cy_LVD_SetInterruptConfig(CY_LVD_INTR_BOTH);

  25.     /* Enable the LVD Block */
  26.     Cy_LVD_Enable();

  27.     /* Provide delay to avoid false interrupt detection */
  28.     Cy_SysLib_DelayUs(20U);

  29.     /* Clear any false interrupt */
  30.     Cy_LVD_ClearInterrupt();

  31.     /* Initialize the LVD interrupt */
  32.     (void)Cy_SysInt_Init(&LVD_interrupt_cfg, LVD_interrupt_handler);

  33.     /* Enables LVD interrupts */
  34.     Cy_LVD_SetInterruptMask();
  35.     NVIC_EnableIRQ(LVD_interrupt_cfg.intrSrc);
  36. }
  37. /* Interrupt Handler */
  38. void LVD_interrupt_handler()
  39. {
  40.     /*Do the necessary processing if the voltage drops below the set threshold */

  41.     /* Clear the interrupt */
  42.     Cy_LVD_ClearInterrupt();
  43. }



您需要登录后才可以回帖 登录 | 注册

本版积分规则

认证:英飞凌科技股份公司
简介:关于英飞凌——我们致力于打造一个更加便利、安全和环保的世界,在赢得自身成功发展的同时,积极践行企业社会责任。

109

主题

279

帖子

8

粉丝
快速回复 在线客服 返回列表 返回顶部