查看: 2757|回复: 0

[分享] 【经验分享】关于LPC845 BOD的问题讨论(续)

[复制链接]

该用户从未签到

656

主题

6312

帖子

0

超级版主

Rank: 8Rank: 8

积分
20071
最后登录
2024-4-29
发表于 2018-8-10 15:53:07 | 显示全部楼层 |阅读模式
本帖最后由 小恩GG 于 2018-8-10 15:56 编辑

关于LPC845 BOD的问题讨论
    写在前面的话
       [url=http://www.nxp.com/cn/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc800-series-cortex-m0-plus-mcus/low-cost-microcontrollers-mcus-based-on-arm-cortex-m0-plus-coresPC84X?lang=cn&lang_cd=zh-Hans&]LPC845[/url]是LPC800入门级MCU新推出的系列之一,相比与原来的LPC824,增加了CRC引擎,FAIM启动配置和电容触摸界面等有特色的模块,可扩展原先的应用场景,并能满足客户进一步的开发需求。
OM13097-LPCXpresso845-MAX-Board.jpg
1 OM13097 LPCXpresso845-MAX Board

       先前,小编曾在论坛中分享过一篇关于BOD相关的帖子:《关于LPC845 BOD的问题讨论》,而本篇文章也是关于LPC845 BOD模块的,算是BOD问题讨论的姊妹篇吧,闲话不多说,进入正题。
     问题
    在调试LPC845 BOD 中断过程中发现,MCU在BOD 中断使能后,即刻响应BOD中断,中间想了很多的方法,比如:清除SYSRSTSTAT(系统复位状态寄存器)中的BOD 位,清除BOD 中断挂起位等,但这些都不奏效,BOD 中断还是一如既往的会被响应, 目前来说,没有对应workaround可以解决这个现象,只能在代码应用中设置忽略第一个中断响应
FIG.jpg
图2 SYSRSTSTAT(系统复位状态寄存器)


      测试代码
    代码来自更改过的[url=http://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-cortex-m-mcus/lpc800-series-cortex-m0-plus-mcus/low-cost-microcontrollers-mcus-based-on-arm-cortex-m0-plus-coresPC84X?tab=Design_Tools_Tab]LPC845 codebundle工程[/url]
  1. #include <stdio.h>
  2. #include "LPC8xx.h"
  3. #include "gpio.h"
  4. #include "syscon.h"
  5. #include "utilities.h"

  6. /*********************************************************************************************************
  7. ** Function name:       myDelay
  8. ** Descriptions:        软件延时
  9. ** input parameters:    ulTime:延时时间(ms)
  10. ** output parameters:   无
  11. ** Returned value:      无
  12. *********************************************************************************************************/
  13. void myDelay (uint32_t ulTime)
  14. {
  15.     uint32_t i;

  16.     while (ulTime--) {
  17.         for (i = 0; i < 2401; i++);
  18.     }
  19. }





  20. void BOD_IRQHandler(void)
  21. {
  22.         
  23.   if (LPC_SYSCON->SYSRSTSTAT & (1 << 3)) {
  24.                 NVIC_DisableIRQ(BOD_IRQn);                 
  25.   }
  26.         
  27.         LED_On(LED_RED);  // Red  LED  
  28.         myDelay (100);
  29.         LED_Off(LED_RED);
  30.         myDelay (100);
  31. }

  32. void BODInit(void)
  33. {
  34.         
  35.   
  36.           // Disable BOD reset function before powering BOD peripheral
  37.         LPC_SYSCON->BODCTRL &= ~(1 << 4);

  38.         // Power up BOD
  39.         LPC_SYSCON->PDRUNCFG &= ~(1 << 3);

  40.         for (uint32_t i = 0; i < 43; i++) __NOP();

  41.         // Enable BOD reset at level 3 (2.63V ~ 2.76V)
  42.         LPC_SYSCON->BODCTRL |= (3 << 0) | (1 << 4);
  43.         
  44.                                  
  45.           NVIC_EnableIRQ(BOD_IRQn);                                    
  46. }

  47. int main(void) {

  48.   SystemInit();

  49.   //清除SYSRSTSTAT(系统复位状态寄存器)中的BOD 位
  50.   LPC_SYSCON->SYSRSTSTAT |= 0xFF;                        
  51.   if( NVIC_GetPendingIRQ(BOD_IRQn) == 1)
  52.       NVIC_ClearPendingIRQ(BOD_IRQn);                    //清除BOD 中断挂起位
  53.    
  54.   Config_LED(LED_RED);
  55.   Config_LED(LED_BLUE);
  56.         
  57.         
  58.   BODInit ();
  59.    
  60.   while (1) {

  61.    LED_On(LED_BLUE);
  62.          myDelay (500);
  63.          LED_Off(LED_BLUE);
  64.          myDelay (500);
  65.                
  66.   }

  67. }
复制代码
关于LPC845 BOD的问题讨论(2).pdf (429.98 KB, 下载次数: 5)
回复

使用道具 举报

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

本版积分规则

关闭

站长推荐上一条 /4 下一条

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2024-4-29 15:06 , Processed in 0.121828 second(s), 22 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

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