Other Parts Discussed in Thread: MSP430F5418A, MSP430F5438A, MSP430F5438
Hi,
I was wondering does anyone have like 5 mins and is experienced with the same microprocessor? I would just like for someone to please help me with a code to get input analog channels 13 and 14 working by ADC12. I'm pretty sure the coding would take 5 mins max. I have tried forums and adjusted my code 50 millions times and it seems correct but the ADC12 just does not work at all. This is my code but it does not work at all. It doesn't make any since because I've referenced and checked it a million times. It should work. I'm just running the ADC12 in a sequence for channels 13 and 14. Although I'm running it multiple times it is only running once every while loops starts. The values I get are not changing no matter what I plug into the pins and sometimes it does not even read. Can someone if possible type a code for me to do this and make sure it works? I have an MSP430-EXPF5438 board. Here is my code, and I am posting it. I have gotten help but to no avail.
#define NumberOfResults 400
volatile unsigned int results1[NumberOfResults];
volatile unsigned int results2[NumberOfResults];
void main (void)
{
int index = 0;
while(1)
{
/*Turns off the watch dog so the infinite loop to rst the program.*/
WDTCTL = WDTPW + WDTHOLD;
P7SEL = BIT5 | BIT6; //Set P7.5(A13) & P7.6(A14) to analog input.
ADC12CTL0 = 0; //Set everything in CTL0 to 0, also making sure ENC is disabled to set the parameters.
ADC12CTL1 = 0; //Set everything in CTL1 to 0.
/*Setting Control 0: Sample and hold cycle for ADC12MEM8 through ADC12MEM15 is 256 CLK cycles,
* multiscan is enabled, 2.5[V] as the reference point, reference on, turns on the ADC.*/
ADC12CTL0 |= ADC12SHT11 | ADC12MSC | ADC12REF2_5V | ADC12REFON | ADC12ON;
/*Setting Control 1: Starting conversion from P7.5(A13), SAMPCON signal is sourced from the sampling timer,
* repeat-sequence-of-channels.*/
ADC12CTL1 |= ADC12CSTARTADD3 | ADC12CSTARTADD2 | ADC12CSTARTADD0 | ADC12CONSEQ0 | ADC12SHP;//ADC12SHP + ADC12CONSEQ_1;
ADC12CTL2 |= ADC12RES1;// | ADC12REFBURST;
ADC12MCTL13 = 0; //Set everything in CTL13 to 0.
ADC12MCTL14 = 0; //Set everything in CTL14 to 0.
/*Setting the */
ADC12MCTL13 |= ADC12SREF0 | ADC12INCH3 | ADC12INCH2 | ADC12INCH0;
ADC12MCTL14 |= ADC12SREF0 | ADC12INCH3 | ADC12INCH2 | ADC12INCH1 | ADC12EOS;
ADC12CTL0 |= ADC12ENC;
while(index < NumberOfResults){
ADC12CTL0 |= ADC12SC;
while(ADC12CTL1 & ADC12BUSY){ //Runs forever, why?
//Do nothing until the conversion sequence is finished.
}
results1[index] = ADC12MEM13;
results2[index] = ADC12MEM14;
index = index + 1;
}
} //End of while (1) loop
} //End of Program
Every time I check ADC12MEM13 and 14, there are no correct conversion values. Can someone please design a code that works? I'm pretty sure this would only take 5 mins because this is the newest code that I've typed and it doesn't work either. : (
Thanks,
Dav