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.
I am using a MSP432 Launchpad and working with the ADC14 module on it. I am using channel A14 via P6.1 on the launchpad. Here's how I have the circuit setup:
My code is given below followed by a description of the problems I am facing.
//*****************************************************************************
//
// MSP432 main.c template - Empty main
//
//****************************************************************************
#include "msp.h"
#include <stdio.h>
#include "msp_compatibility.h"
#include <stdint.h>
void ADC_INIT();
void getADC();
volatile unsigned long rawVolt;
double adc_Volt;
int flag;
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
ADC_INIT();
while(1)
{
getADC();
}
}
void ADC_INIT()
{
/*Some bits can only be configured while the enable bit is 0*/
ADC14->CTL0 &= ~ADC14_CTL0_ENC;
/*Select the SEL1:0 registers to configure P6.1 to perform the tertiary ADC function*/
P6->SEL1 |= BIT1;
P6->SEL0 |= BIT1;
/*Select sample and hold time = 16 cycles, turn ADC14 ON, single-channel repeated conversion*/
ADC14->CTL0 |= ADC14_CTL0_SHT0__16 + ADC14_CTL0_ON + ADC14_CTL0_CONSEQ_2;
ADC14->CTL1 |= ADC14_CTL1_RES__14BIT; //Select 14-bit resolution
ADC14->MCTL[0] |= ADC14_MCTLN_INCH_14; //Configure MTCL0 to select channel A14 i.e P6.1
ADC14->CTL0 |= ADC14_CTL0_ENC; //Enable ADC
}
void getADC()
{
ADC14->CTL0 |= ADC14_CTL0_SC; //Start Conversion
flag = ADC14_IFGR0_IFG0 & BIT0; //Set 'flag' equal to conversion complete flag for MEM0
while(!(flag)); //wait for 'flag' to be set
rawVolt = ADC14->MEM[0];
//rawVolt = ADC14->MEM[0] & 0x0000FFFF;
adc_Volt = ((3.3 * rawVolt)/(16384.0)); //Vr+ = AVcc = 3.3V, Vr- = AVss = GND
}
Now every time I run this code, I notice a few things. 1. Even though I've setup the MEM0 register, all my MEM registers contain some values and I don't know where they're coming from 2. The actual MEM0 register, or my variable rawVolt, keep switching between a few recurring values no matter which way I turn the potentiometer. These values are incorrect because when I put a multimeter to my potentiometer output, I get a very different reading than what my variable adc_volt says. 3. I keep getting the following error every now and then:
"CORTEX_M4_0: JTAG Communication Error: (Error -1170 @ 0x0) Unable to access the DAP. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 6.0.83.1)"
4. My XMS432 and IC101 chips on the launchpad get very, very hot.
My main concern at the moment is the incorrect conversion result. Any help is appreciated!
Hi Bhoomi!
Bhoomi Patel said:I keep getting the following error every now and then: "CORTEX_M4_0: JTAG Communication Error: (Error -1170 @ 0x0) Unable to access the DAP. Reset the device, and retry the operation. If error persists, confirm configuration, power-cycle the board, and/or try more reliable JTAG settings (e.g. lower TCLK). (Emulation package 6.0.83.1)"
You may want to have a look here:
ISSUES WITH THE DEBUG XDS110 AND MSP432 - MSP low-power microcontroller forum - MSP low-power microcontrollers...
At the end it shows where to change the JTAG communication speed. You can at least give it a try.
Bhoomi Patel said:My XMS432 and IC101 chips on the launchpad get very, very hot.
See your other post here:
MSP432 Overheating - MSP low-power microcontroller forum - MSP low-power microcontrollers - TI E2E support...
Dennis
Bhoomi,
regarding your code - I will first insert it again using the Syntaxhighlighter:
#include "msp.h" #include <stdio.h> #include "msp_compatibility.h" #include <stdint.h> void ADC_INIT(); void getADC(); volatile unsigned long rawVolt; double adc_Volt; int flag; void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer ADC_INIT(); while(1) { getADC(); } } void ADC_INIT() { /*Some bits can only be configured while the enable bit is 0*/ ADC14->CTL0 &= ~ADC14_CTL0_ENC; /*Select the SEL1:0 registers to configure P6.1 to perform the tertiary ADC function*/ P6->SEL1 |= BIT1; P6->SEL0 |= BIT1; /*Select sample and hold time = 16 cycles, turn ADC14 ON, single-channel repeated conversion*/ ADC14->CTL0 |= ADC14_CTL0_SHT0__16 + ADC14_CTL0_ON + ADC14_CTL0_CONSEQ_2; ADC14->CTL1 |= ADC14_CTL1_RES__14BIT; //Select 14-bit resolution ADC14->MCTL[0] |= ADC14_MCTLN_INCH_14; //Configure MTCL0 to select channel A14 i.e P6.1 ADC14->CTL0 |= ADC14_CTL0_ENC; //Enable ADC } void getADC() { ADC14->CTL0 |= ADC14_CTL0_SC; //Start Conversion flag = ADC14_IFGR0_IFG0 & BIT0; //Set 'flag' equal to conversion complete flag for MEM0 while(!(flag)); //wait for 'flag' to be set rawVolt = ADC14->MEM[0]; //rawVolt = ADC14->MEM[0] & 0x0000FFFF; adc_Volt = ((3.3 * rawVolt)/(16384.0)); //Vr+ = AVcc = 3.3V, Vr- = AVss = GND }
There are two faults in line 37:
ADC14->CTL0 |= ADC14_CTL0_SHT0__16 + ADC14_CTL0_ON + ADC14_CTL0_CONSEQ_2;
You are sampling a single channel and trigger each new conversion yourself, so use CONSEQ_0 instead of CONSEQ_2 (you can simply delete CONSEQ_2 since it is CONSEQ_0 by default).
Additionally you need to set ADC14_CTL0_SHP as well. So your line 37 should look like this:
ADC14->CTL0 |= ADC14_CTL0_SHT0__16 | ADC14_CTL0_ON | ADC14_CTL0_SHP;
This should work then.
Dennis
I see where my mistake lies. So if I was to start a conversion at the end of my ADC initialization and remove it from the getADC() function, CONSEQ_2 would make sense, correct?
As far as SHP goes, I had looked at the manual and wanted SHP to be set so that "0b = SAMPCON signal is sourced from the sample-input signal" so I didn't touch it. Clearly I did not understand the purpose of that bit fully. I'm still new to the TI MSP world.
Thank you so much for your help. The ADC definitely gets the right values now.
For the heating issue: I looked at the post you suggested, and I think your solution is to add a capacitor in parallel to C125?
JTAG Connection Error: I have already tried that solution once to no avail. However, I will give it another shot.
Bhoomi
**Attention** This is a public forum