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.

MSP430F413: Program loop

Part Number: MSP430F413

In my MSP430F413 design, Pin 47 (P16/CA0) is connected to a sensor. When the

sensor is not connected. The program goes into a loop :

----------------------------------------------------------------------------------------------------------

C1_pH

                BIT.B      #CAOUT,&CACTL2                           ; Comparator out hi/low?

                JNZ         C1_pH

-----------------------------------------------------------------------------------------------------------

 

&CACTL2 always shows 000Dh (0000 1101). Unable to change to 000Ch.

CAOUT is : #define CAOUT               (0x01)

Only when sensor is connected, &CACTL2  change to 000Ch.

 

Is there any instruction that I can add in such that it'll could come out of the loop when no sensor

is connected.

  • If the sensor is disconnected (pin is floating) it could read as anything. The only thing I can think of is to avoid the loop entirely if the sensor is disconnected.

    When I want to see if a pin is floating, I "nudge" it up/down/both and see if it reacts. I usually do this with the pullup/down (REN) resistors to reduce bus contention in the case something is really connected. It appears the F413 doesn't have those. I suspect you could do this by setting the pin (briefly) as an output (CAPD.6=0, P1DIR.6=1); if you only do this for a few microseconds it probably won't cause any trouble.

**Attention** This is a public forum