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.

CCS/MSP430FR4133: ADC Register Conversion From MSP430FR6989

Part Number: MSP430FR4133
Other Parts Discussed in Thread: MSP430FR6989

Tool/software: Code Composer Studio

Hi all,

I wrote this code block for ADC conversion for MSP430FR6989. It worked well. My question is, I want to implement same code on MSP430FR4133, the things is when I write the same code for it, LED is not working. Also I don't have any building error. It might be related with 12-bit ADC to 10-bit ADC conversion in my code. I also suspect "PM5CTL0 = ENABLE_PINS" line to be faulty. Please check the code blocks.

Application should be like that:

Between 0.8V and 1.2V, P1.0(LED) must be high. Else, low. 

Working code in MSP430FR6989 

#include <msp430.h>
#define ENABLE_PINS 0xFFFE // Enables inputs and outputs
void ADC_SETUP(void); // Used to setup ADC12 peripheral
main()
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
PM5CTL0 = ENABLE_PINS; // Enable inputs and outputs
P1DIR = BIT0; // Set RED LED to output
ADC_SETUP(); // Sets up ADC peripheral
while(1)
{
ADC12CTL0 = ADC12CTL0 | ADC12ENC; // Enable conversion
ADC12CTL0 = ADC12CTL0 | ADC12SC; // Start conversion
if ((ADC12MEM0 >= 0x3C0)&&(ADC12MEM0<=0x5C0)) // 0.8V<Voltage<1.2V HIGH
{
P1OUT = BIT0; // Turn on red LED
}
else // Else input <= 1.65V
{
P1OUT = 0x00; // Turn off red LED
}
}// end while(1)
}// end main()

void ADC_SETUP(void)
{
#define ADC12_SHT_16 0x0200 // 16 clock cycles for sample and hold
#define ADC12_ON 0x0010 // Used to turn ADC12 peripheral on
#define ADC12_SHT_SRC_SEL 0x0200 // Selects source for sample & hold
#define ADC12_12BIT 0x0020 // Selects 12-bits of resolution
#define ADC12_P92 0x000A // Use input P9.2 for analog input
ADC12CTL0 = ADC12_SHT_16 | ADC12_ON ; // Turn on, set sample & hold time
ADC12CTL1 = ADC12_SHT_SRC_SEL; // Specify sample & hold clock source
ADC12CTL2 = ADC12_12BIT; // 12-bit conversion results
ADC12MCTL0 = ADC12_P92; // P9.2 is analog input
}

Not working code in MSP430FR4133 for same function. 

#include <msp430.h>
#define ENABLE_PINS 0xFFFE // Enables inputs and outputs
void ADC_SETUP(void); // Used to setup ADC12 peripheral

main(){
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
PM5CTL0 = PM5CTL0 & ENABLE_PINS; // Enable inputs and outputs
P1DIR = BIT0; // Set RED LED to output
ADC_SETUP(); // Sets up ADC peripheral

while(1){

ADCCTL0 = ADCCTL0 | ADCENC; // Enable conversion
ADCCTL0 = ADCCTL0 | ADCSC; // Start conversion
if ((ADCMEM0 >= 0x0F0)&&(ADCMEM0<=0x170)){ // 0.8V<Voltage<1.2V HIGH
P1OUT = BIT0; // Turn on red LED
}
else { // Else
P1OUT = 0x00; // Turn off red LED
}
} // end while(1)
} // end main()

void ADC_SETUP(void)

{
#define ADC_SHT_16 0x0200 // 16 clock cycles for sample and hold
#define ADC_ON 0x0010 // Used to turn ADC12 peripheral on
#define ADC_SHT_SRC_SEL 0x0200 // Selects source for sample & hold
#define ADC_12BIT 0x0020 // Selects 12-bits of resolution
#define ADC_P81 0x0009 // Use input P8.1 for analog input --->A9
ADCCTL0 = ADC_SHT_16 | ADC_ON ; // Turn on, set sample & hold time
ADCCTL1 = ADC_SHT_SRC_SEL; // Specify sample & hold clock source
ADCCTL2 = ADC_12BIT; // 12-bit conversion results
ADCMCTL0 = ADC_P81; // P8.1 is analog input --->A9
}

Best Regards, Ali.

 

**Attention** This is a public forum