Hey Guys,
i try the "MSP432 Comparator - Interrupt Capability; Vcompare is compared against internal 1.2V reference" - Example
after line
MAP_Interrupt_enableInterrupt(COMP_E0_MODULE);
the MSP432 jump into:
static void FaultISR(void)
{
//
// Enter an infinite loop.
//
while(1)
{
}
}
and no Compare Interupt will be execute.
Full Example main.c:
/*
* -------------------------------------------
* MSP432 DriverLib - v2_20_00_08
* -------------------------------------------
*
* --COPYRIGHT--,BSD,BSD
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
/******************************************************************************
* MSP432 Comparator - Interrupt Capability; Vcompare is compared against
* internal 1.2V reference
*
* Description: Use COMPE and internal reference to determine if input'Vcompare'
* is high or low. For the first time, when Vcompare exceeds the 1.2V internal
* reference, CEIFG is set and device enters the COMPE ISR. In the ISR, CEIES is
* toggled such that when Vcompare is less than 1.2V internal reference;
* CEIFG is set. The LED is toggled inside the ISR to illustrate the change.
* The filter feature of the Comp module is used to filter out any noise on
* the line and assure no spurious interrupts occur.
*
* MSP432P401
* ------------------
* /|\| |
* | | |
* --|RST P10.4/C0.7 |<--Vcompare
* | |
* | P1.0|----> 'high'(Vcompare>1.2V); 'low'(Vcompare<1.2)
* | | |
* | | | LED 'ON'(Vcompare>1.2V); 'OFF'(Vcompare<1.2V)
* | |
*
* Author: Timothy Logan
******************************************************************************/
/* DriverLib Includes */
#include "driverlib.h"
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
/* Comparator configuration structure */
const COMP_E_Config compConfig =
{
COMP_E_VREF, // Positive Input Terminal
COMP_E_INPUT7, // Negative Input Terminal
COMP_E_FILTEROUTPUT_DLYLVL4, // Delay Level 4 Filter
COMP_E_NORMALOUTPUTPOLARITY // Normal Output Polarity
};
int main(void)
{
/* Stop WDT */
MAP_WDT_A_holdTimer();
/* Set P1.0 as an output pin for LED */
MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
/* Set P10.4 to be comparator in (C0.7) */
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P10, GPIO_PIN4,
GPIO_TERTIARY_MODULE_FUNCTION);
/* Initialize the Comparator module
* Comparator Instance 1
* Pin CE07 to Positive(+) Terminal
* Reference Voltage to Negative(-) Terminal
* Normal Power Mode
* Output Filter On with max delay
* Non-Inverted Output Polarity
*/
MAP_COMP_E_initModule(COMP_E0_MODULE, &compConfig);
/*
* Base Address of Comparator E,
* Reference Voltage of 1.2 V,
* Lower Limit of 1.2*(32/32) = 1.2V,
* Upper Limit of 1.2*(32/32) = 1.2V
*/
MAP_COMP_E_setReferenceVoltage(COMP_E0_MODULE, COMP_E_VREFBASE1_2V, 32, 32);
/* Enable COMP_E Interrupt on default rising edge for CEIFG */
MAP_COMP_E_setInterruptEdgeDirection(COMP_E0_MODULE, COMP_E_RISINGEDGE);
/* Enable Interrupts
* Comparator Instance 1,
* Enable COMPE Interrupt on default rising edge for CEIFG
*/
MAP_COMP_E_clearInterruptFlag(COMP_E0_MODULE, COMP_E_OUTPUT_INTERRUPT);
MAP_COMP_E_enableInterrupt(COMP_E0_MODULE, COMP_E_OUTPUT_INTERRUPT);
MAP_Interrupt_enableSleepOnIsrExit();
MAP_Interrupt_enableInterrupt(COMP_E0_MODULE);
MAP_Interrupt_enableMaster();
/* Allow power to Comparator module */
MAP_COMP_E_enableModule(COMP_E0_MODULE);
while (1)
{
/* Goto Sleep */
PCM_gotoLPM0();
}
}
/******************************************************************************
*
* This is the COMP_VECTOR interrupt vector service routine.
*
******************************************************************************/
void comp_isr(void)
{
/* Toggle the edge at which an interrupt is generated */
MAP_COMP_E_toggleInterruptEdgeDirection(COMP_E0_MODULE);
/* Clear Interrupt flag */
MAP_COMP_E_clearInterruptFlag(COMP_E0_MODULE, COMP_E_OUTPUT_INTERRUPT);
/* Toggle P1.0 output pin */
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
}
Full startup-file:
/*
* -------------------------------------------
* MSP432 DriverLib - v2_20_00_08
* -------------------------------------------
*
* --COPYRIGHT--,BSD,BSD
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// Forward declaration of the default fault handlers.
//
//*****************************************************************************
void ResetISR(void);
static void NmiSR(void);
static void FaultISR(void);
static void IntDefaultHandler(void);
//*****************************************************************************
//
// External declaration for the reset handler that is to be called when the
// processor is started
//
//*****************************************************************************
extern void _c_int00(void);
//*****************************************************************************
//
// Linker variable that marks the end of the stack.
//
//*****************************************************************************
extern unsigned long __STACK_END;
//*****************************************************************************
//
// External declarations for the interrupt handlers used by the application.
//
//*****************************************************************************
extern void comp_isr(void);
//*****************************************************************************
//
// The vector table. Note that the proper constructs must be placed on this to
// ensure that it ends up at physical address 0x0000.0000 or at the start of
// the program if located at a start address other than 0.
//
//*****************************************************************************
#pragma DATA_SECTION(g_pfnVectors, ".intvecs")
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((unsigned long)&__STACK_END),
// The initial stack pointer
ResetISR, // The reset handler
NmiSR, // The NMI handler
FaultISR, // The hard fault handler
IntDefaultHandler, // The MPU fault handler
IntDefaultHandler, // The bus fault handler
IntDefaultHandler, // The usage fault handler
0, // Reserved
0, // Reserved
0, // Reserved
0, // Reserved
IntDefaultHandler, // SVCall handler
IntDefaultHandler, // Debug monitor handler
0, // Reserved
IntDefaultHandler, // The PendSV handler
IntDefaultHandler, // The SysTick handler
IntDefaultHandler, // PSS ISR
IntDefaultHandler, // CS ISR
IntDefaultHandler, // PCM ISR
IntDefaultHandler, // WDT ISR
IntDefaultHandler, // FPU ISR
IntDefaultHandler, // FLCTL ISR
comp_isr, // COMP_E0_MODULE ISR
IntDefaultHandler, // COMP_E1_MODULE ISR
IntDefaultHandler, // TA0_0 ISR
IntDefaultHandler, // TA0_N ISR
IntDefaultHandler, // TA1_0 ISR
IntDefaultHandler, // TA1_N ISR
IntDefaultHandler, // TA2_0 ISR
IntDefaultHandler, // TA2_N ISR
IntDefaultHandler, // TA3_0 ISR
IntDefaultHandler, // TA3_N ISR
IntDefaultHandler, // EUSCIA0 ISR
IntDefaultHandler, // EUSCIA1 ISR
IntDefaultHandler, // EUSCIA2 ISR
IntDefaultHandler, // EUSCIA3 ISR
IntDefaultHandler, // EUSCIB0 ISR
IntDefaultHandler, // EUSCIB1 ISR
IntDefaultHandler, // EUSCIB2 ISR
IntDefaultHandler, // EUSCIB3 ISR
IntDefaultHandler, // ADC12 ISR
IntDefaultHandler, // T32_INT1 ISR
IntDefaultHandler, // T32_INT2 ISR
IntDefaultHandler, // T32_INTC ISR
IntDefaultHandler, // AES ISR
IntDefaultHandler, // RTC ISR
IntDefaultHandler, // DMA_ERR ISR
IntDefaultHandler, // DMA_INT3 ISR
IntDefaultHandler, // DMA_INT2 ISR
IntDefaultHandler, // DMA_INT1 ISR
IntDefaultHandler, // DMA_INT0 ISR
IntDefaultHandler, // PORT1 ISR
IntDefaultHandler, // PORT2 ISR
IntDefaultHandler, // PORT3 ISR
IntDefaultHandler, // PORT4 ISR
IntDefaultHandler, // PORT5 ISR
IntDefaultHandler, // PORT6 ISR
IntDefaultHandler, // Reserved 41
IntDefaultHandler, // Reserved 42
IntDefaultHandler, // Reserved 43
IntDefaultHandler, // Reserved 44
IntDefaultHandler, // Reserved 45
IntDefaultHandler, // Reserved 46
IntDefaultHandler, // Reserved 47
IntDefaultHandler, // Reserved 48
IntDefaultHandler, // Reserved 49
IntDefaultHandler, // Reserved 50
IntDefaultHandler, // Reserved 51
IntDefaultHandler, // Reserved 52
IntDefaultHandler, // Reserved 53
IntDefaultHandler, // Reserved 54
IntDefaultHandler, // Reserved 55
IntDefaultHandler, // Reserved 56
IntDefaultHandler, // Reserved 57
IntDefaultHandler, // Reserved 58
IntDefaultHandler, // Reserved 59
IntDefaultHandler, // Reserved 60
IntDefaultHandler, // Reserved 61
IntDefaultHandler, // Reserved 62
IntDefaultHandler, // Reserved 63
IntDefaultHandler // Reserved 64
};
//*****************************************************************************
//
// This is the code that gets called when the processor first starts execution
// following a reset event. Only the absolutely necessary set is performed,
// after which the application supplied entry() routine is called. Any fancy
// actions (such as making decisions based on the reset cause register, and
// resetting the bits in that register) are left solely in the hands of the
// application.
//
//*****************************************************************************
void ResetISR(void)
{
//
// Jump to the CCS C Initialization Routine.
//
__asm(" .global _c_int00\n"
" b.w _c_int00");
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a NMI. This
// simply enters an infinite loop, preserving the system state for examination
// by a debugger.
//
//*****************************************************************************
static void NmiSR(void)
{
//
// Enter an infinite loop.
//
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives a fault
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void FaultISR(void)
{
//
// Enter an infinite loop.
//
while(1)
{
}
}
//*****************************************************************************
//
// This is the code that gets called when the processor receives an unexpected
// interrupt. This simply enters an infinite loop, preserving the system state
// for examination by a debugger.
//
//*****************************************************************************
static void IntDefaultHandler(void)
{
//
// Go into an infinite loop.
//
while(1)
{
}
}
EDIT:
insert c-code and use collapse, and load the original startup-file, the problem is still awake.