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.

MSP430FR2676: Unable to configure XOUT as GPIO

Part Number: MSP430FR2676


Hi, I am having trouble configuring and using XOUT as a GPIO (P2.0)

Here is the code i have to configure the pin -

P2SEL0 &= ~(BIT0);
P2SEL1 &= ~(BIT0);

P2DIR = BIT0;
P2OUT = BIT0;

PM5CTL0 &= ~LOCKLPM5; // Engage GPIOs

but I am not reading a high value on the pin. Am i missing a step in configuring XOUT as a GPIO?

  • Hey Audrey,

    At first, glance that looks okay to me. 

    Can you look at the registers while debugging and confirm that they are set correctly?   

    Anything on the hardware that could be pulling the signal down?  

    Thanks,

    JD

  • Hi JD,

    I am seeing that the P2 register is set to 0x01 when I set the pin high, and 0x00 when I set to low.

    Should I check any other registers?

    There is not currently anything hooked up to pin 2.0, I am just probing the test point with a DMM and measuring a low voltage each time.

  • What does P2IN.0 say? That should show the actual pin state.

    How is P2.1 (XIN) configured?

    What platform (board) are you using? Is there any other code we should know about?

  • P2IN.0 is 1, even when i set the output low.

    P2OUT.0 is matching what I set the pin state to, 0 for low and 1 for high

    P2.1 is actually configured to the XIN mode. There is an external crystal hooked up to this pin. I am using custom hardware.

    I saw the following note in the datasheet after further investigation - " It is also possible to apply digital clock signals to the XIN input pin that meet the specifications of the respective oscillator if the appropriate XT1BYPASS mode is selected. In this case, the associated XOUT pin can be used for other purposes. "

    Based on this note, perhaps I am missing this XT1BYPASS configuration to allow me to use XOUT as a GPIO. (there are not external bypass capacitors on XIN and XOUT in the current hardware design). Do you know which register I need to update to change the XT1BYPASS setting? From what I am reading in the users guide, it sounds like bypass mode disables the external clock. "XT1 is configured for bypass mode of operation, and the oscillator associated with XT1 is powered down"

  • Try:

    > CSCTL6 |= XT1BYPASS;   // Use only XIN for oscillator

    [Ref User Guide (SLAU445I) Table 3-10]

    [Edit: I just noticed your final question. The oscillator that is "powered down" is the XT1 oscillator circuit inside the MCU, since in Bypass mode it will just get in the way. It doesn't (can't) power down your external oscillator.]

  • Bruce,

    This is great, I am now reading the expected voltage output at the pin! Thanks for the clarification.

    Will this have an impact on my clock settings? I have a 32.768 kHz external crystal tied to XIN. I am running at 16MHz when not in sleep mode, using the DCO clock source. I just want to make sure that making this change is not impacting my other settings.

    Thanks again

  • Point of terminology:

    1) An "external crystal" refers to just a crystal, (usually) with two capacitors. It requires two pins (XIN/XOUT) and it works with the oscillator circuitry (XT1) inside the MCU. If you disconnect XOUT it won't oscillate. 

    2) An "external oscillator" is a separate "box" containing both the crystal and the oscillator circuitry. It requires only one MCU pin (XIN), and doesn't need XT1 nor XOUT, but you have to tell the Clock System that that's what you're doing (XT1BYPASS).

    It would be useful to know what platform (board) you're using. If it's a custom board, a schematic would be useful.

  • Ok, I am using an external oscillator on a custom board.

    The 32.768kHz external oscillator has a CLKOUT line that is connected to XIN of the MSP430. The remaining connections on the oscillator are power and ground.

  • It sounds like you have the configuration you want. This won't disturb the rest of your clocking.

    Looking at the CS schematic [Ref User Guide (SLAU445I) Fig 3-1], XT1BYPASS serves as what amounts to a selector that says "switch off XOUT" (here XT1OUT). Everything else runs as usual.

  • Thanks so much Bruce!

**Attention** This is a public forum