Part Number:MSP432P401R
Tool/software: Code Composer Studio
Hey, Guys
I have this example code working with my Temperature sensor at A1 port. It was working yesterday, and when I try to debug again today. I have this Invalid response/ Target is busy from my debugger (no matter how many time I power off and back on). I could not connect to my chip anymore because of this. I'm using this MSP432P401R chip for my own project. Also this is the 3rd chip acting like this.
I was using ADC through Energia (Example ADC code in Energia library) and as soon as I upload the code it will give me these (Invalid response from XDS110/ Target is busy) response.(changed a new chip and load ADC example again it will still doing that). Then, I changed another new chip again and using code composer this time(use a code composer example code) , the problem was gone and seems working properly for yesterday. Now this afternoon the problem is back(Cannot connect my chip) when I paused the program and check the variable values. I'm really confused.
When this happens, the chips seems like stop functioning because same program loaded in there previously seems like stop working as well.(LED won't come on)
This code is when the pin get more than 1.6V the LED will on. (I put a 220 ohm resistor between the I/O and my LED).
/* --COPYRIGHT--,BSD_EX
* Copyright (c) 2013, 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.
*
*******************************************************************************
*
* MSP432 CODE EXAMPLE DISCLAIMER
*
* MSP432 code examples are self-contained low-level programs that typically
* demonstrate a single peripheral function or device feature in a highly
* concise manner. For this the code may rely on the device's power-on default
* register values and settings such as the clock configuration and care must
* be taken when combining code from several examples to avoid potential side
* effects. Also see www.ti.com/.../mspdriverlib for an API functional
* library & https://dev.ti.com/pinmux/ for a GUI approach to peripheral configuration.
*
* --/COPYRIGHT--*/
//******************************************************************************
//******************************************************************************
// MSP432P401 Demo - ADC14, Sample A1, AVcc Ref, Set P1.0 if A1 > 0.5*AVcc
//
// Description: A single sample is made on A1 with reference to AVcc.
// Software sets ADC14_CTL0_SC to start sample and conversion - ADC14_CTL0_SC
// automatically cleared at EOC. ADC14 internal oscillator times sample (16x)
// and conversion. In Mainloop MSP432 waits in LPM0 to save power until ADC14
// conversion complete, ADC14_ISR will force exit from LPM0 in Mainloop on
// reti. If A1 > 0.5*AVcc, P1.0 set, else reset. The full, correct handling of
// and ADC14 interrupt is shown as well.
//
//
// MSP432P401x
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// >---|P5.4/A1 P1.0|-->LED
//
// William Goh
// Texas Instruments Inc.
// June 2016 (updated) | November 2013 (created)
// Built with CCSv6.1, IAR, Keil, GCC
//******************************************************************************
#include <ti/devices/msp432p4xx/inc/msp.h>
#include "math.h"
#include <stdint.h>
#include <stdio.h>
int main(void) {
volatile unsigned int i;
volatile unsigned long rawVolt;
float adc_Volt;
float temperatureC;
float temperatureF;
float average;
float average1;
float steinhart;
WDT_A->CTL = WDT_A_CTL_PW | // Stop WDT
WDT_A_CTL_HOLD;
// GPIO Setup
P2->OUT &= ~BIT4; // Clear LED to start
P2->DIR |= BIT4; // Set P2.4/LED to output
P5->SEL1 |= BIT4; // Configure P5.4 for ADC
P5->SEL0 |= BIT4;
// Enable global interrupt
__enable_irq();
// Enable ADC interrupt in NVIC module
NVIC->ISER[0] = 1 << ((ADC14_IRQn) & 31);
// Sampling time, S&H=16, ADC14 on
ADC14->CTL0 = ADC14_CTL0_SHT0_2 | ADC14_CTL0_SHP | ADC14_CTL0_ON;
ADC14->CTL1 = ADC14_CTL1_RES_2; // Use sampling timer, 12-bit conversion results
ADC14->MCTL[0] |= ADC14_MCTLN_INCH_1; // A1 ADC input select; Vref=AVCC
ADC14->IER0 |= ADC14_IER0_IE0; // Enable ADC conv complete interrupt
SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk; // Wake up on exit from ISR
// Ensures SLEEPONEXIT takes effect immediately
__DSB();
while (1)
{
for (i = 20000; i > 0; i--); // Delay
// Start sampling/conversion
ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC;
rawVolt = ADC14->MEM[0];
adc_Volt = ((3.3 * rawVolt)/(4096));
average = ((10000 * rawVolt)/((4096)- (rawVolt)));
steinhart = average / 10000; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= 3950; // 1/B * ln(R/Ro)
steinhart += 1.0 / (25 + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
temperatureC = steinhart;
temperatureF = (steinhart * 9.0)/ 5.0 + 32.0;
}
}
// ADC14 interrupt service routine
void ADC14_IRQHandler(void) {
if (ADC14->MEM[0] >= 0x7FF) // ADC12MEM0 = A1 > 0.5AVcc?
P2->OUT |= BIT4; // P2.0 = 4
else
P2->OUT &= ~BIT4; // P2.0 = 4
}