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.
Tool/software: Code Composer Studio
I have configured the three channel sequential interrupt. ADC channel like A7,A6 and A4.
Note:
A7 and A6 is working while sequential interrupt. But if add A4 channel. Which is not working. Please give me suggestion.
Note:
Here i have made algo for two channel sequential interrupt. But after conversion random channel value is stored in to ADCMEM0 register. Means (ADC channel A7: )value must available in ADC_Result[0] but instead of that A6th channel value is be in ADC_Result[0].
EXAM :: ADC_Result[0] = A7 channel data , ADC_Result[1]= A6 channel data instead of that ADC_Result[0] = A6 and ADC_Result[1] = A7. Values comes like that. Please check the code and let me know .
void ADC_ChannelSelection()
{
//SYSCFG2 |= ADCPCTL0 |ADCPCTL1 | ADCPCTL2; // P2.2, P2.4 AND P2.5 No port selection only has channel Selection
SYSCFG2 |= ADCPCTL7;
SYSCFG2 |= ADCPCTL6;
// SYSCFG2 |= ADCPCTL5;
// SYSCFG2 |= ADCPCTL4;
}
void ADC_Configuration(void)
{
// Configure ADC
ADCCTL0 |= ADCSHT_2 | ADCON; // 16ADCclks, ADC ON
ADCCTL1 |= ADCSHP | ADCSSEL_2; // ADC clock MODCLK, sampling timer, TA1.1B trig.,repeat sequence
ADCCTL2 |= ADCRES_1; // 10-bit conversion results
ADCMCTL0 |=ADCINCH_7; // A7(EoS); Vref=3.3V
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
}
void ADC_SamplingTrigger(void)
{
ADCCTL0 |= ADCON;
SYSCFG2 |= ADCPCTL7;
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
SYSCFG2 &= ~ADCPCTL7;
ADCCTL0 |= ADCENC;
ADCCTL0 |= ADCON;
SYSCFG2 |= ADCPCTL6;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL0 |= ADCENC |ADCSC;
SYSCFG2 &= ~ADCPCTL6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 &= ~ADCON;
}
void ADC_convertionDta(void)
{
//V2_TVSLekageNegative += (float)ADC_Result[3]; // channel 0 P2.2 A4 TVS Leakage Negative(V2)
V_Earth += (float)ADC_Result[0]; //A6 th channel //channel 1 P2.4 A6 earth(com)(V)
V1_TVSLeakagePositive += (float)ADC_Result[1]; //A7 th channel
//channel 2 P2.5 A7 TVS leakage Positive(V1)
// DummuVoltage += (float)ADC_Result[2]; // Channel p2.3 A5
//V2_TVSLekageNegative += (float)ADC_Result[3]; // channel 0 P2.2 A4 TVS Leakage Negative(V2)
count++;
if(count >= MAXCOUNT)
{
V2_TVSLekageNegative = V2_TVSLekageNegative / MAXCOUNT;
V_Earth = V_Earth / MAXCOUNT;
V1_TVSLeakagePositive = V1_TVSLeakagePositive / MAXCOUNT;
DummuVoltage = DummuVoltage/1;
DummuVoltage1 = ((DummuVoltage *ADCREF) / (BITRESOLUTION));
#if 1
V2_Negative =((V2_TVSLekageNegative *ADCREF) / (BITRESOLUTION)); //((count * Vref)/ADCResolution)
V0_COM = ((V_Earth *ADCREF) / (BITRESOLUTION));
V1_Positive = ((V1_TVSLeakagePositive *ADCREF)/ (BITRESOLUTION));
#endif
count =0;
V2_TVSLekageNegative =0;
V_Earth =0;
V1_TVSLeakagePositive=0;
DummuVoltage =0;
}
}
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
{
if(i<2)
{
ADC_Result[i] = ADCMEM0;
i++;
}
else
{
i=0;
}
//__bic_SR_register_on_exit(LPM0_bits);
ADCCTL0 &=~ADCON;
}
Hi Mutharagan,
Could you provide more detail in what you mean by channel A4 "not working" when you add it? Are you ensuring you are configuring channel 4 in the ADC_ChannelSelection() and void ADC_SamplingTrigger() functions?
To make the ADC channels read in the correct data, can you read the data using a decrementing variable rather than an incrementing variable to get the data in the right order? Like the following:
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
{
if(i>0)
{
ADC_Result[i] = ADCMEM0;
i--;
}
else
{
i=2;
}
//__bic_SR_register_on_exit(LPM0_bits);
I have tested the interrupt via decremental method. I am using three channel like A7,A6 and A4. But onlt two channel only working fine the channel A4 is not working.
i have tried so many ways but not able fetching 3 channel continuous interrupt, Please give me solution. Based on that we can go for further development. Polling method is working fine. But project is to be done by Interrupt method.
Note:
1. In Application Guide they are giving flow diagram for polling method only. Based on the diagram i have completed ADC CONVERSION for polling method. But for interrupt i am using same technics.
void ADC_ChannelSelection()
{
//SYSCFG2 |= ADCPCTL0 |ADCPCTL1 | ADCPCTL2; // P2.2, P2.4 AND P2.5 No port selection only has channel Selection
SYSCFG2 |= ADCPCTL7;
//SYSCFG2 |= ADCPCTL6;
//SYSCFG2 |= ADCPCTL5;
SYSCFG2 |= ADCPCTL4;
}
void ADC_Configuration(void)
{
// Configure ADC
ADCCTL0 |= ADCSHT_2 | ADCON; // 16ADCclks, ADC ON
ADCCTL1 |= ADCSHP | ADCSSEL_2; // ADC clock MODCLK, sampling timer, TA1.1B trig.,repeat sequence
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL2 |= ADCRES_1; // 10-bit conversion results
//ADCMCTL0 |=ADCINCH_7; // A7(EoS); Vref=3.3V
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
}
//Please find below so many method using . But i can't achieve //////
void ADC_SamplingTrigger(void)
{
//1. This is first Method
switch(ADCStatus)
{
case CHANNEL7 :
ADCCTL0 |= ADCON;
//SYSCFG2 |= ADCPCTL7;
ADCIE |= ADCIE0;
// ADCCTL1 |= ADCCONSEQ_1;
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
//while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCChannel7flag =1;
break;
case CHANNEL6 :
ADCCTL0 |= ADCON;
//SYSCFG2 |= ADCPCTL6;
ADCIE |= ADCIE0;
//ADCCTL1 |= ADCCONSEQ_1;
ADCMCTL0 |=ADCINCH_4;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
//while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCChannel6flag =1;
break;
case CHANNEL5 :
break;
}
//2. Second Method
#if 0
ADCCTL0 |= ADCON;
SYSCFG2 |= ADCPCTL7;
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
SYSCFG2 &= ~ADCPCTL7;
ADCCTL0 |= ADCENC;
ADCCTL0 |= ADCON;
SYSCFG2 |= ADCPCTL6;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL0 |= ADCENC |ADCSC;
SYSCFG2 &= ~ADCPCTL6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 &= ~ADCON;
#endif
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
//ADCCTL0 &= ~ADCENC;
//ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
//ADCCTL0 &= ~ADCENC;
//ADCMCTL0 |=ADCINCH_5;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC;
// while(ADCIFG & ADCIFG0);
ADCCTL0 &= ~ADCENC;
#endif
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
// ADCCTL0 &= ~ADCENC;
#endif
// As per flow diagram which has been developed for continuous interrupt method. Only two ADC channels working fine. if i add one more channel every thing gets affected.
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ADCENC;
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
//ISR
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
{
static long int Counter, Counter1, Counter2;
//Using Switch case and flag concept i am trying to control the channel .At the time only one channel is working fine.
if(ADCChannel7flag)
{
ADC_Result[0] = ADCMEM0;
ADCChannel7Count += ADC_Result[0];
Counter++;
ADCChannel7flag =0;
if(Counter >100)
{
Counter =0;
ADCChannel7Count = ADCChannel7Count/100;
ADCChannel7Volt = ADCChannel7Count* 3.3/1024;
ADCChannel7Count =0;
ADCStatus = CHANNEL6;
ADCIE &= ~ADCIE0;
///SYSCFG2 &= ~ADCPCTL7;
ADCCTL0 &= ~ADCON;
}
}
else if(ADCChannel6flag)
{
ADC_Result[1] = ADCMEM0;
ADCChannel6Count += ADC_Result[1];
Counter1++;
ADCChannel6flag =0;
if(Counter1 >100)
{
Counter1 =0;
ADCChannel6Count = ADCChannel6Count/100;
ADCChannel6Volt = ADCChannel6Count* 3.3/1024;
ADCChannel6Count =0;
ADCStatus = CHANNEL7;
ADCIE &= ~ADCIE0;
//SYSCFG2 &= ~ADCPCTL6;
ADCCTL0 &= ~ADCON;
}
}
//In this method. Two channel is working fine. Can't get the value if i add more than two channel.
#if 0
if(i>0)
{
ADC_Result[i] = ADCMEM0;
i--;
}
else
{
i=3;
}
#endif
//__bic_SR_register_on_exit(LPM0_bits);
}
Part Number: MSP-TS430RHL20
Tool/software: Code Composer Studio
Dear Sir,
Pease find below details for facing issues in MSP430FR2422.
Note: Exam CODE is given by Texas . Which is working only A2,A1 and A0 channel. But problem is if i am going to use A7. A6 and A4 sequence interrupt is not working. I have tried so many ways based on the MSP430FR2X family Guide (the flow diagram for ADC Polling method).
I have tested the interrupt via decremental method. I am using three channel like A7,A6 and A4. But only two channel only working fine the channel A4 is not working.
i have tried so many ways but not able fetching 3 channel continuous interrupt, Please give me solution. Based on that we can go for further development. Polling method is working fine. But project is to be done by Interrupt method.
Note:
1. In Application Guide they are giving flow diagram for polling method only. Based on the diagram i have completed ADC CONVERSION for polling method. But for interrupt i am using same technics.
void ADC_ChannelSelection()
{
//SYSCFG2 |= ADCPCTL0 |ADCPCTL1 | ADCPCTL2; // P2.2, P2.4 AND P2.5 No port selection only has channel Selection
SYSCFG2 |= ADCPCTL7;
//SYSCFG2 |= ADCPCTL6;
//SYSCFG2 |= ADCPCTL5;
SYSCFG2 |= ADCPCTL4;
}
void ADC_Configuration(void)
{
// Configure ADC
ADCCTL0 |= ADCSHT_2 | ADCON; // 16ADCclks, ADC ON
ADCCTL1 |= ADCSHP | ADCSSEL_2; // ADC clock MODCLK, sampling timer, TA1.1B trig.,repeat sequence
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL2 |= ADCRES_1; // 10-bit conversion results
//ADCMCTL0 |=ADCINCH_7; // A7(EoS); Vref=3.3V
ADCIE |= ADCIE0; // Enable ADC conv complete interrupt
}
//Please find below so many method using . But i can't achieve //////
void ADC_SamplingTrigger(void)
{
//1. This is first Method
switch(ADCStatus)
{
case CHANNEL7 :
ADCCTL0 |= ADCON;
//SYSCFG2 |= ADCPCTL7;
ADCIE |= ADCIE0;
// ADCCTL1 |= ADCCONSEQ_1;
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
//while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCChannel7flag =1;
break;
case CHANNEL6 :
ADCCTL0 |= ADCON;
//SYSCFG2 |= ADCPCTL6;
ADCIE |= ADCIE0;
//ADCCTL1 |= ADCCONSEQ_1;
ADCMCTL0 |=ADCINCH_4;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
//while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCChannel6flag =1;
break;
case CHANNEL5 :
break;
}
//2. Second Method
#if 0
ADCCTL0 |= ADCON;
SYSCFG2 |= ADCPCTL7;
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
SYSCFG2 &= ~ADCPCTL7;
ADCCTL0 |= ADCENC;
ADCCTL0 |= ADCON;
SYSCFG2 |= ADCPCTL6;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL1 |= ADCCONSEQ_3;
ADCCTL0 |= ADCENC |ADCSC;
SYSCFG2 &= ~ADCPCTL6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 &= ~ADCON;
#endif
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC; //ENC High low to high start the sampling process
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
//ADCCTL0 &= ~ADCENC;
//ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
//ADCCTL0 &= ~ADCENC;
//ADCMCTL0 |=ADCINCH_5;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC;
// while(ADCIFG & ADCIFG0);
ADCCTL0 &= ~ADCENC;
#endif
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC; //ENC lOW
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
// ADCCTL0 &= ~ADCENC;
#endif
// As per flow diagram which has been developed for continuous interrupt method. Only two ADC channels working fine. if i add one more channel every thing gets affected.
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ADCENC;
#if 0
ADCMCTL0 |=ADCINCH_7;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
ADCMCTL0 |=ADCINCH_6;
ADCCTL0 &= ~ADCENC;
ADCCTL0 |= ADCENC |ADCSC;
while(ADCIFG & ADCIFG0);
//ADCCTL0 |= ADCENC;
ADCCTL0 &= ~ADCENC;
//ISR
#pragma vector=ADC_VECTOR
__interrupt void ADC_ISR(void)
{
static long int Counter, Counter1, Counter2;
//Using Switch case and flag concept i am trying to control the channel .At the time only one channel is working fine.
if(ADCChannel7flag)
{
ADC_Result[0] = ADCMEM0;
ADCChannel7Count += ADC_Result[0];
Counter++;
ADCChannel7flag =0;
if(Counter >100)
{
Counter =0;
ADCChannel7Count = ADCChannel7Count/100;
ADCChannel7Volt = ADCChannel7Count* 3.3/1024;
ADCChannel7Count =0;
ADCStatus = CHANNEL6;
ADCIE &= ~ADCIE0;
///SYSCFG2 &= ~ADCPCTL7;
ADCCTL0 &= ~ADCON;
}
}
else if(ADCChannel6flag)
{
ADC_Result[1] = ADCMEM0;
ADCChannel6Count += ADC_Result[1];
Counter1++;
ADCChannel6flag =0;
if(Counter1 >100)
{
Counter1 =0;
ADCChannel6Count = ADCChannel6Count/100;
ADCChannel6Volt = ADCChannel6Count* 3.3/1024;
ADCChannel6Count =0;
ADCStatus = CHANNEL7;
ADCIE &= ~ADCIE0;
//SYSCFG2 &= ~ADCPCTL6;
ADCCTL0 &= ~ADCON;
}
}
//In this method. Two channel is working fine. Can't get the value if i add more than two channel.
#if 0
if(i>0)
{
ADC_Result[i] = ADCMEM0;
i--;
}
else
{
i=3;
}
#endif
//__bic_SR_register_on_exit(LPM0_bits);
}
The FR2 ADC sequence counts from ADCINCH down to A0, in your case A7->A0. [Ref User Guide (SLAU445I) Fig 21-16]
When ADCINCH=2, as in the Example, this is A2->A0, which is pretty easy. In your case you need to pick out the channel results you want, as they arrive.
Hi Mutharagan,
After investigating further into the User's Guide (Section 21.2.7.4), when using Repeat-Sequence-of-Channels Mode (ADCCONSEQ_3), the sequence begins with the selected channel ADCINCHx and decrements down to channel A0. So when incrementing in your original code in the ISR, you need to make sure that you read ADCMEM0 at the correct counts to read A7, A6, and A4.
I have an E2E thread that may help: e2e.ti.com/.../279076
This thread looks like a duplicate of this one:
https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/950609/3513069#3513069
This thread looks like a duplicate of this one:
https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/950173/3514696
**Attention** This is a public forum