EmbeddedRelated.com
Forums
Memfault Beyond the Launch

ADC10 problem reading three channels

Started by Leon Heller November 9, 2005
I'm trying to read three consecutive inputs from A0, A1 and A2 with an

'F1232, but only get the first input. I've set ENC to 0 and 1
according to 
SLAU049.pdf, section 18.2.1. Here's the section of code that isn't
working:

SetupADC10  mov.w   #ADC10SHT_2+ADC10ON+ADC10IE,&ADC10CTL0 ; 16x,
enable 
int.

                                            ;
Mainloop
 ; Read A0
            bic.w #ENC,&ADC10CTL0
 bis.b    #01h,&ADC10AE           ; ADC10 A0 select and enable
 bis.w       #ENC+ADC10SC,&ADC10CTL0 ; Start sampling/conversion
            bis.w       #CPUOFF+GIE,SR          ; LPM0, ADC10_ISR will force

exit
            mov.w       &ADC10MEM,R6 ; Read ADC A0
            call        #TXW  ; Transmit data (four ASCII digits)
            mov.b #' ',R6  ; Space
            call #TX_CHAR

 ; Read A1
            bic.w #ENC,&ADC10CTL0
 bis.b    #02h,&ADC10AE           ; ADC10 A1 select and enable
 bis.w       #ENC+ADC10SC,&ADC10CTL0 ; Start sampling/conversion
            bis.w       #CPUOFF+GIE,SR          ; LPM0, ADC10_ISR will force

exit
            mov.w       &ADC10MEM,R6 ; Read ADC A1
            call        #TXW  ; Transmit data (four ASCII digits)
            mov.b #' ',R6  ; Space
            call #TX_CHAR

 ; Read A2
            bic.w #ENC,&ADC10CTL0
 bis.b    #04h,&ADC10AE           ; ADC10 A2 select and enable
 bis.w       #ENC+ADC10SC,&ADC10CTL0 ; Start sampling/conversion
            bis.w       #CPUOFF+GIE,SR          ; LPM0, ADC10_ISR will force

exit
            mov.w       &ADC10MEM,R6 ; Read ADC A2
            call        #TXW  ; Transmit data (four ASCII digits)

 ; Send new line
            mov.b #0x0D,R6
            call #TX_CHAR
            mov.b #0x0A,R6
            call #TX_CHAR

            jmp         Mainloop

Leon
--
Leon Heller, G1HSM
leon.heller@leon...
http://webspace.webring.com/people/jl/leon_heller/ 

---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


Beginning Microcontrollers with the MSP430

Leon why not simply use the single or repeat consecutive sequence of 
samples mode? To do this you simple set the MSC bit to 1, then set the 
end of sequence channel to 0010, and finally enable the first 3 
channels. the interrupt will occur automatically after completion of the 
third conversion.

This is not as powerful or as flexible as the ADC12, since you cannot 
assign channels in to conversion channels, and are stuck with taking the 
channels in sequence, but in your case this works fine.

CXheers

Al

Leon Heller wrote:

>I'm trying to read three consecutive inputs
from A0, A1 and A2 with an 
>'F1232, but only get the first input. I've set ENC to 0 and 1
according to 
>SLAU049.pdf, section 18.2.1. Here's the section of code that isn't
working:
>
>SetupADC10  mov.w   #ADC10SHT_2+ADC10ON+ADC10IE,&ADC10CTL0 ;
16x, enable 
>int.
>
>                                            ;
>Mainloop
> ; Read A0
>            bic.w #ENC,&ADC10CTL0
> bis.b    #01h,&ADC10AE           ; ADC10 A0 select and enable
> bis.w       #ENC+ADC10SC,&ADC10CTL0 ; Start sampling/conversion
>            bis.w       #CPUOFF+GIE,SR          ; LPM0, ADC10_ISR will
force 
>exit
>            mov.w       &ADC10MEM,R6 ; Read ADC A0
>            call        #TXW  ; Transmit data (four ASCII digits)
>            mov.b #' ',R6  ; Space
>            call #TX_CHAR
>
> ; Read A1
>            bic.w #ENC,&ADC10CTL0
> bis.b    #02h,&ADC10AE           ; ADC10 A1 select and enable
> bis.w       #ENC+ADC10SC,&ADC10CTL0 ; Start sampling/conversion
>            bis.w       #CPUOFF+GIE,SR          ; LPM0, ADC10_ISR will
force 
>exit
>            mov.w       &ADC10MEM,R6 ; Read ADC A1
>            call        #TXW  ; Transmit data (four ASCII digits)
>            mov.b #' ',R6  ; Space
>            call #TX_CHAR
>
> ; Read A2
>            bic.w #ENC,&ADC10CTL0
> bis.b    #04h,&ADC10AE           ; ADC10 A2 select and enable
> bis.w       #ENC+ADC10SC,&ADC10CTL0 ; Start sampling/conversion
>            bis.w       #CPUOFF+GIE,SR          ; LPM0, ADC10_ISR will
force 
>exit
>            mov.w       &ADC10MEM,R6 ; Read ADC A2
>            call        #TXW  ; Transmit data (four ASCII digits)
>
> ; Send new line
>            mov.b #0x0D,R6
>            call #TX_CHAR
>            mov.b #0x0A,R6
>            call #TX_CHAR
>
>            jmp         Mainloop
>
>Leon
>--
>Leon Heller, G1HSM
>leon.heller@leon...
>http://webspace.webring.com/people/jl/leon_heller/ 
>
>---
>[This E-mail has been scanned for viruses but it is your responsibility 
>to maintain up to date anti virus software on the device that you are
>currently using to read this email. ]
>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>
>
>  
>


----- Original Message ----- 
From: "Onestone" <onestone@ones...>
To: <msp430@msp4...>
Sent: Wednesday, November 09, 2005 2:56 PM
Subject: Re: [msp430] ADC10 problem reading three channels


> Leon why not simply use the single or repeat
consecutive sequence of 
> samples mode? To do this you simple set the MSC bit to 1, then set the 
> end of sequence channel to 0010, and finally enable the first 3 
> channels. the interrupt will occur automatically after completion of the 
> third conversion.
> 
> This is not as powerful or as flexible as the ADC12, since you cannot 
> assign channels in to conversion channels, and are stuck with taking the 
> channels in sequence, but in your case this works fine.

Thanks, Al.

I was intending to try that next. It's a neater way to do it, anyway.

Leon
---
[This E-mail has been scanned for viruses but it is your responsibility 
to maintain up to date anti virus software on the device that you are
currently using to read this email. ]



Memfault Beyond the Launch