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.

MSP430FR2355: Problem using the analog to digital converter

Part Number: MSP430FR2355

;-------------------------------------------------------------------------------
            ORG     08000h                  ; Program Reset
;-------------------------------------------------------------------------------


;******************************************************************************
#include  "msp430fr2355.h"
;-------------------------------------------------------------------------------

RESET       mov     #03000h,SP               ; Initialize stackpointer
StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL     ; Stop WDT
MeasurePulse
            clr     &ADCMCTL0
            mov     #ADCSHT_1+ADCON,&ADCCTL0
            mov     #ADCDIV_1,&ADCCTL1
            mov     #ADCRES_2,&ADCCTL2
            mov.b   #0FFh,&P1DIR
            mov.b   #0FFh,&P1SEL0
            mov.b   #0FFh,&P1SEL1
A2DConversion
            bic     #ADCIFG0,&ADCIFG
            bis     #ADCENC+ADCSC,&ADCCTL0
A2DLoop
            bit     #ADCIFG0,&ADCIFG
            jz      A2DLoop
            bic     #ADCENC+ADCSC,&ADCCTL0
            mov     &ADCMEM0,R4
            ret
            
;-------------------------------------------------------------------------------
            ORG     0FFFEh
            DW      RESET
            END

This is my code for the MSP430FR2355.  It does an A/D read from A0.  I clear the ADCIFG0 flag just prior to starting the conversion.  Then I poll the ADCIFG0 flag to see when it completes the conversion, but it never comes out of the A2DLoop segment.  The ADCIFG0 flag remains 0 forever.  What am I doing wrong?

  • I don't know which assembler you are using but the use of absolute addresses is different to me. I let the linker locate things.

    Setting every bit of the P1SELx registers is just asking for trouble. Set the bits you need and no others.

    P1DIR is don't care when the module function is selected.

    On any FRAM device you need to think about the LOCKLPM5 bit which locks GPIO settings until cleared.

  • This is an excerpt from a larger program that I'm working on, which is why all the P1SELx bits are set (I'm using all the op amps on the MSP430FR2355).  Setting P1DIR on unused and don't care bits is something I do reflexively to avoid possible additional current drain on floating input pins.

    I did try clearing the LOCKLPM5 bit on PM5CTL0, even though I think this is just for GPIO.

    Problem is still the same.

    By the way, the ADCBUSY bit is also set, indicating that the microcontroller thinks it is still converting.

  • >  mov #ADCDIV_1,&ADCCTL1

    With SHP=0, the sample/hold will never end. Try instead something like:

    >  mov #ADCDIV_1+ADCSHP,&ADCCTL1

  • Wow!  That was it.  Thanks!

**Attention** This is a public forum