本帖最后由 小恩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启动配置和电容触摸界面等有特色的模块,可扩展原先的应用场景,并能满足客户进一步的开发需求。 图1 OM13097 LPCXpresso845-MAX Board
先前,小编曾在论坛中分享过一篇关于BOD相关的帖子:《关于LPC845 BOD的问题讨论》,而本篇文章也是关于LPC845 BOD模块的,算是BOD问题讨论的姊妹篇吧,闲话不多说,进入正题。 问题
在调试LPC845 BOD 中断过程中发现,MCU在BOD 中断使能后,即刻响应BOD中断,中间想了很多的方法,比如:清除SYSRSTSTAT(系统复位状态寄存器)中的BOD 位,清除BOD 中断挂起位等,但这些都不奏效,BOD 中断还是一如既往的会被响应, 目前来说,没有对应workaround可以解决这个现象,只能在代码应用中设置忽略第一个中断响应。 图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] - #include <stdio.h>
- #include "LPC8xx.h"
- #include "gpio.h"
- #include "syscon.h"
- #include "utilities.h"
- /*********************************************************************************************************
- ** Function name: myDelay
- ** Descriptions: 软件延时
- ** input parameters: ulTime:延时时间(ms)
- ** output parameters: 无
- ** Returned value: 无
- *********************************************************************************************************/
- void myDelay (uint32_t ulTime)
- {
- uint32_t i;
- while (ulTime--) {
- for (i = 0; i < 2401; i++);
- }
- }
- void BOD_IRQHandler(void)
- {
-
- if (LPC_SYSCON->SYSRSTSTAT & (1 << 3)) {
- NVIC_DisableIRQ(BOD_IRQn);
- }
-
- LED_On(LED_RED); // Red LED
- myDelay (100);
- LED_Off(LED_RED);
- myDelay (100);
- }
- void BODInit(void)
- {
-
-
- // Disable BOD reset function before powering BOD peripheral
- LPC_SYSCON->BODCTRL &= ~(1 << 4);
- // Power up BOD
- LPC_SYSCON->PDRUNCFG &= ~(1 << 3);
- for (uint32_t i = 0; i < 43; i++) __NOP();
- // Enable BOD reset at level 3 (2.63V ~ 2.76V)
- LPC_SYSCON->BODCTRL |= (3 << 0) | (1 << 4);
-
-
- NVIC_EnableIRQ(BOD_IRQn);
- }
- int main(void) {
- SystemInit();
- //清除SYSRSTSTAT(系统复位状态寄存器)中的BOD 位
- LPC_SYSCON->SYSRSTSTAT |= 0xFF;
- if( NVIC_GetPendingIRQ(BOD_IRQn) == 1)
- NVIC_ClearPendingIRQ(BOD_IRQn); //清除BOD 中断挂起位
-
- Config_LED(LED_RED);
- Config_LED(LED_BLUE);
-
-
- BODInit ();
-
- while (1) {
- LED_On(LED_BLUE);
- myDelay (500);
- LED_Off(LED_BLUE);
- myDelay (500);
-
- }
- }
复制代码 |