Hello,
do you have a example implementation for BOD LPC4317?
I wrote the following lines:
// Bown-Out Detect voltage level (0-3)
uint32_t bodVoltageLevel = 3; // interrupt level 3 (3.05V)
// Brown-Out Reset voltage level (0-3)
uint32_t borVolatgeReset = 0; // reset level 0 (1.9V)
NVIC_DisableIRQ(EVENTROUTER_IRQn);
// Initialize the event router.
Chip_EVRT_Init();
// Configures the BOD level and reset level on LPC18xx/LPC43xx parts.
// Note: BOD reset is not used!
Chip_CREG_ConfigureBODaR(bodVoltageLevel, borVolatgeReset);
// Set up the type of interrupt type for a source to EVRT.
// Level configuration register (HILO)
// Edge configuration (EDGE)
// HILO bit n EDGE bit n Description
// 0 0 Detect LOW level (currently active)
// 0 1 Detect falling edge
// 1 0 Detect HIGH level
// 1 1 Detect rising edge
Chip_EVRT_ConfigIntSrcActiveType(EVRT_SRC_BOD1, EVRT_SRC_ACTIVE_LOW_LEVEL);
// ***
// Event Enable register (ENABLE)
// The ENABLE register can be read at any time. To change the contents of this register, use
// the CLR_EN and SET_EN registers.
// Set event enable register (SET_EN)
// The SET_EN register sets the corresponding bits in the ENABLE register.
// Enable interrupt sources to EVRT. Source is BOD.
// BOD interrupt. Not active in Deep-sleep, Power-down, and
// Deep power-down mode. Use for wake-up from Sleep mode.
// Note: BOD reset is not used!
Chip_EVRT_SetUpIntSrc(EVRT_SRC_BOD1, ENABLE);
// Clear event enable register (CLR_EN)
// The CLR_EN register clears the corresponding bits in the ENABLE register.
// Nothing to do.
// ***
// Event status register (STATUS)
// The STATUS register monitors the internally generated interrupt or event signal from the
// peripherals. The contents of this register can be read at any time. To change the contents
// of this register, use the CLR_STAT and SET_STAT registers.
// Set event status register (SET_STAT)
// Nothing to do.
// Clear event status register (CLR_STAT)
// Clear pending interrupt EVRT source. Source is BOD.
Chip_EVRT_ClrPendIntSrc(EVRT_SRC_BOD1);
// ***
// Set irq event router priority
NVIC_SetPriority(EVENTROUTER_IRQn, 1); // High priority
// Clear a pending event router interrupt
NVIC_ClearPendingIRQ(EVENTROUTER_IRQn);
// Enable event router interrupt
NVIC_EnableIRQ(EVENTROUTER_IRQn);
The IRQ Looks like:
void EVRT_IRQHandler(void)
{
// For debugging, remove later again
__nop();
// Check if a source is sending interrupt to EVRT
if (SET == Chip_EVRT_IsSourceInterrupting(EVRT_SRC_BOD1))
{
Chip_EVRT_ClrPendIntSrc(EVRT_SRC_BOD1);
}
}
My Problem is, after I activate the IRQ NVIC_EnableIRQ(EVENTROUTER_IRQn);, the MCU jumps into the IRQ-handlder. Why?
Another Problem is, that I can not reset the Status reg via Chip_EVRT_ClrPendIntSrc(EVRT_SRC_BOD1); The function call has no effect?
What is wrong? Thank's for any Feedback!