This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP-EXP432P401R Resets when external crystal and RTC enabled.

Hello,

I am attempting to evaluate the MSP-EXP432P401R board to determine if the msp432 will accommodate our power requirements, and I am running into an issue I am hoping someone can shed some light on.

My code is pretty simple, in that it disables the supervisor/monitors, initializes the GPIO, sets the up clocks (with external crystal), then sets up the RTC to use the prescalar interrupts, looking for an interrupt every .5 seconds.  Lastly I flicker an LED for roughly 1 second then enable the interrupts, start the RTC clock, and enter LPM3.

When I run the code through the debug interface in CCS, it runs smooth with no problems.  However as soon as i disconnect from the interface, and let the board run solely on USB power, I find that my LED keeps flickering, indicating I keep resetting and constantly am executing in main.  

If I keep all the code but do not start the RTC clock, the code will only flicker the LED once (indicating it is not resetting).  So the problem appears to be in the RTC in that simply running the RTC clock causes some kind of reset (I also have infinite while loops set for all ISRs, so I can assume I am not getting a fault interrupt otherwise it would not reset and just constantly loop forever.

Any insight would be excellent.  I attached my source code, maybe you guys can pick out my error.

int main(void)
{

    /* Stop Watchdog  */
	MAP_WDT_A_holdTimer();
    /*
     * Disable PSS
     */
    MAP_PSS_disableHighSide();
    MAP_PSS_disableLowSide();
    /*
     * Disabling SRAM bank 1. This also disables banks 2-7
     */
//    MAP_SysCtl_disableSRAMBank(SYSCTL_SRAM_BANK1);
	/*
	 * Initialize the GPIO outputs
	 */
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P2, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P3, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P4, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P5, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P6, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P7, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P8, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P9, PIN_ALL8);
	MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P10, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0 | GPIO_PIN2 | GPIO_PIN3 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P2, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P3, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P4, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P5, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P6, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P7, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P8, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P9, PIN_ALL8);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_P10, PIN_ALL8);
	MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1 | GPIO_PIN4);
	MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_PJ, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION);
	MAP_GPIO_setAsOutputPin(GPIO_PORT_PJ, GPIO_PIN4 | GPIO_PIN5);
	/*
	 * Setup the core voltage
	 * 	Target: 16 MHz
	 * 	LDO Mode => Vcore0 max at 24MHz
	 * 	DCDC Mode => Vcore0 max at 48MHz
	 * 	Peripherals max at 12MHz Vcore0, 24 MHz Vcore1
	 * 	Flash will all be normal reads, so Vcore0 means we need 1 flash wait-states (see data sheet for more details)
	 */
    MAP_PCM_setCoreVoltageLevel(PCM_VCORE0);
	MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
	MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);
	MAP_CS_setDCOFrequency(16000000);
	/*
	 * Setup the LFXT external crystal
	 */
	MAP_CS_setExternalClockSourceFrequency(32768, 48000000);
	MAP_CS_startLFXT(CS_LFXT_DRIVE0);
	/*
	 * Initialize the clock sources
	 */
	MAP_CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1);
	MAP_CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);
	MAP_CS_initClockSignal(CS_HSMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2);
	MAP_CS_initClockSignal(CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
	MAP_CS_initClockSignal(CS_BCLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);

	/*
	 * Setup RTC for LPM3 at 1 second intervals
	 */
	MAP_RTC_C_holdClock();
	MAP_RTC_C_definePrescaleEvent(RTC_C_PRESCALE_0, RTC_C_PSEVENTDIVIDER_256);
	MAP_RTC_C_definePrescaleEvent(RTC_C_PRESCALE_1, RTC_C_PSEVENTDIVIDER_128);
	//RTCPS = 0x0000;
	//RTCPS1CTL = RT1IP_5;
	MAP_RTC_C_clearInterruptFlag(RTC_C_PRESCALE_TIMER1_INTERRUPT);
	MAP_RTC_C_enableInterrupt(RTC_C_PRESCALE_TIMER1_INTERRUPT);
    /*
     * Enable the interrupt in the NVIC
     */
    MAP_Interrupt_enableInterrupt(INT_RTC_C);

    /*
     * Toggle LED
     */
    MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
    __delay_cycles(8000000);
    MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);

	/*
	 * Enable interrupts
	 */
    MAP_Interrupt_enableSleepOnIsrExit();
    MAP_Interrupt_enableMaster();
    MAP_RTC_C_startClock();

    while(1)
    {
    	lpm_status = MAP_PCM_gotoLPM3InterruptSafe();
    }
}

void Isr_RTC(void)
{
	switch (RTCIV)
	{
		case 0:
		case 2:
		case 4:
		case 6:
		case 8:
		case 10:
		default:
			break;
		case 12:
			rtc_counter++;
			break;
	}
}

  • Hi Chris,

    Have you done any testing to see if the clock source has any impact (i.e. running off the internal clock instead of external)? Also, what are your jumper and JTAG Switch configurations?

    Mike
  • Hi Chris,
    one thing that I noticed is that you commented out the SRAM bank configuration. Note that by default, only one SRAM bank is retained when going into LPM3. Since most likely your stack is located on top of SRAM (if you haven't modified the linker command file), all SRAM banks should be enabled to ensure you don't lose your SRAM bank content when you come back from LPM3. This might explain why you experience the crashes, since every time you wake up from LPM3 to service the RTC interrupt, the stack content is gone and the CPU could potentially run into the weeds.
    Try :
    1. Add this line of code MAP_SysCtl_enableSRAMBank(SYSCTL_SRAM_BANK7);
    AND
    2. Make sure your msp432_startup_ccs.c has already added the Isr_RTC function entry into the interrupt vector table.

    Hope that helps!
    ~Dung

**Attention** This is a public forum