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.

Grace 3 does not initialize PxOUT

Other Parts Discussed in Thread: MSP430FR5739
In the comment and code extracted below, it is clear that this routine SHOULD set the PxOUT registers, but it does not in Grace 3.0.  The previous Grace 2 routine GPIO_graceinit did set these registers.  As a workaround I have set them in the user code preamble, but shouldn't Grace do this for you? I believe this is a bug in Grace 3.0.


/*======== PinMux_graceInit ======== * Initialize * * The PinMux registers should be set in a specific order: * PxOUT * PxSEL or PxSELx * PxDIR * PxREN * PxIES * PxIFG * PxIE * * This will ensure that: * - IFG doesn't get set by manipulating the pin function, edge * select, and pull-up/down resistor functionalities (see * Section 8.2.6 of the MSP430 User's manual) * - Glitch-free setup (configuring the OUT register _before_ * setting the pin direction) * - Pull-up/pull-down resistor enable with the correct direction * (.up. vs. .down.) */ void PinMux_graceInit(void)

  • Mike,

    This is a known issue:

    [Bug 3019] Unused GPIO registers are not being initialized

    It will be address in the next Grace point release, 3.00.01.

    Regards,

    Joe

  • Thanks for the reply. Your link is not available. But the title suggests it is different. 

    In my case I initialized the PxOUT value in Grace, and it completely ignored my specification. 

  • Can you attach the cfg script or at least the PinMux portion?

    Regards,

    Joe

  • Here is the whole script. Incidentally today, I am having another related problem, even if I open this file, all the GPIO definitions are lost.  It is very troubling.  It seems like there is more than just this file being considered, because even when I restore the previous version that worked, it erases all the GPIO definitions when I reopen it. Is there a workspace cache that can be cleared out?

    Thanks.

    /**
    * @fileOverview Grace
    */

    /* need to use the CSL module to generate the CSL code */
    var CSL = xdc.useModule('ti.mcu.msp430.csl.CSL');
    var PMM = xdc.useModule('ti.mcu.msp430.csl2.pmm.PMM');
    var REF = xdc.useModule('ti.mcu.msp430.csl2.ref.REF');
    var Comparator_D = xdc.useModule('ti.mcu.msp430.csl2.comparator.Comparator_D');
    var Timer0_A3 = xdc.useModule('ti.mcu.msp430.csl2.timer.Timer0_A3');
    var EUSCI_A1 = xdc.useModule('ti.mcu.msp430.csl2.communication.EUSCI_A1');
    var EUSCI_A0 = xdc.useModule('ti.mcu.msp430.csl2.communication.EUSCI_A0');
    var Timer0_B3 = xdc.useModule('ti.mcu.msp430.csl2.timer.Timer0_B3');
    var Timer2_B3 = xdc.useModule('ti.mcu.msp430.csl2.timer.Timer2_B3');
    var EUSCI_B0 = xdc.useModule('ti.mcu.msp430.csl2.communication.EUSCI_B0');
    var Timer1_A3 = xdc.useModule('ti.mcu.msp430.csl2.timer.Timer1_A3');
    var CS = xdc.useModule('ti.mcu.msp430.csl2.clock.CS');
    var WDT_A = xdc.useModule('ti.mcu.msp430.csl2.watchdog.WDT_A');
    CSL.configApiVersion = "1.20.00";
    var System = xdc.useModule('ti.mcu.msp430.csl2.system.System');
    var GPIO = xdc.useModule('ti.mcu.msp430.csl2.gpio.GPIO');
    var PinMux = xdc.module('ti.mcu.msp430.csl2.pinmux.PinMux')
    var InterruptVectors = xdc.useModule('ti.mcu.msp430.csl.interrupt_vectors.InterruptVectors');

    /* set stack and heap sizes as appropriate for MSP430 */
    Program.sysStack = 0;
    Program.stack = 64;
    Program.heap = 0;
    Program.argSize = 0;

    /* Enable global interrupt */
    System.srRegs.SR.GIE = System.srDefs.GIE;
    PinMux.regs.pjsel0 = 48;
    System.sfrie1Regs.interruptSource[1].interruptEnable = false;
    System.sfrie1Regs.interruptSource[1].interruptHandler = true;
    System.sfrie1Regs.interruptSource[4].interruptHandler = true;
    CSL.device.vcc = 2.5;
    PMM.showUserModePage = true;
    PMM.pmmEnSVSL = false;
    System.sfrie1Regs.interruptSource[0].interruptEnable = true;
    System.sfrie1Regs.interruptSource[0].interruptHandler = true;
    REF.refMode = REF.baseDefs.REFBasicMode;
    REF.refEnable = true;
    REF.refEnableTempSensor = false;
    Comparator_D.compdDisableInputBuffers = true;
    Comparator_D.compdUseRefClkMode = true;
    Comparator_D.compdMode = Comparator_D.baseDefs.ComparatorMode;
    Comparator_D.compdExBInputPin = Comparator_D.COMPD_INPUT13;
    Comparator_D.compdVolRef = Comparator_D.COMPD_VREFBASE1_5V;
    Comparator_D.regs.interruptSource[0].interruptEnable = false;
    Comparator_D.regs.interruptSource[0].interruptHandler = false;
    Comparator_D.regs.interruptSource[1].interruptHandler = false;
    Comparator_D.compdAdvSettings = true;
    PinMux.regs.p2sel1 = 119;
    PinMux.regs.p1sel1 = 192;
    Timer0_A3.timerMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer").IntervalMode;
    Timer0_A3.intervalModeActive = true;
    Timer0_A3.compareValue[0] = 3276;
    Timer0_A3.regs.interruptSource[1].interruptEnable = false;
    Timer0_A3.regs.interruptSource[1].interruptHandler = true;
    Timer0_A3.intervalModeAdvanced = true;
    Timer0_A3.TACTL.timerClockSourceDivider = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_A").TIMERA_CLOCKSOURCE_DIVIDER_1;
    Timer0_A3.TACTL.timerClockSource = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_A").TIMERA_CLOCKSOURCE_ACLK;
    PinMux.regs.p1dir = 23;
    Comparator_D.compdExAInputPin = Comparator_D.COMPD_NOCONN;
    EUSCI_A1.eusciMode = EUSCI_A1.eusciBaseDefs.SPIMode;
    EUSCI_A1.eusciSPI.eusciSPIMode = EUSCI_A1.eusciSPIDefs.MasterMode_3Wire;
    EUSCI_A1.eusciSPI.eusciSPIPin[3] = 0;
    EUSCI_A1.eusciSPI.eusciSPIPin[2] = 1;
    EUSCI_A1.eusciSPI.eusciSPIPin[1] = 1;
    EUSCI_A1.eusciSPI.eusciSPIPin[0] = 1;
    EUSCI_A1.eusciSPI.eusciSPIBitRate = EUSCI_A1.eusciSPIDefs.SPIBitRate_Custom;
    EUSCI_A1.regs.interruptSource[0].interruptEnable = false;
    EUSCI_A1.regs.interruptSource[0].interruptHandler = true;
    EUSCI_A1.regs.interruptSource[1].interruptHandler = true;
    EUSCI_A1.regs.interruptSource[1].interruptEnable = false;
    Comparator_D.compdShowInvertOutput = false;
    Comparator_D.compdShortInputs = false;
    PinMux.regs.p1sel0 = 0;
    PinMux.regs.p3dir = 171;
    PinMux.regs.p3sel1 = 34;
    PinMux.regs.p3sel0 = 34;
    PinMux.regs.p4dir = 2;
    GPIO.regs.interruptSource[0].interruptHandler = false;
    GPIO.regs.interruptSource[1].interruptHandler = false;
    GPIO.regs.interruptSource[2].interruptHandler = false;
    GPIO.regs.interruptSource[3].interruptHandler = false;
    GPIO.regs.interruptSource[4].interruptHandler = false;
    GPIO.regs.interruptSource[5].interruptHandler = false;
    GPIO.regs.interruptSource[6].interruptHandler = false;
    GPIO.regs.interruptSource[7].interruptHandler = false;
    GPIO.regs.interruptSource[8].interruptHandler = false;
    GPIO.regs.interruptSource[9].interruptHandler = false;
    GPIO.regs.interruptSource[10].interruptHandler = false;
    GPIO.regs.interruptSource[11].interruptHandler = false;
    GPIO.regs.interruptSource[12].interruptHandler = false;
    GPIO.regs.interruptSource[13].interruptHandler = false;
    GPIO.regs.interruptSource[14].interruptHandler = false;
    GPIO.regs.interruptSource[15].interruptHandler = false;
    GPIO.regs.interruptSource[16].interruptHandler = true;
    GPIO.regs.interruptSource[17].interruptHandler = true;
    GPIO.regs.interruptSource[18].interruptHandler = true;
    GPIO.regs.interruptSource[19].interruptHandler = true;
    GPIO.regs.interruptSource[20].interruptHandler = true;
    GPIO.regs.interruptSource[21].interruptHandler = true;
    GPIO.regs.interruptSource[22].interruptHandler = true;
    GPIO.regs.interruptSource[23].interruptHandler = true;
    GPIO.regs.interruptSource[24].interruptHandler = true;
    GPIO.regs.interruptSource[25].interruptHandler = true;
    PinMux.regs.p3ren = 80;
    PinMux.regs.p1ren = 48;
    PinMux.regs.p4ren = 1;
    PinMux.regs.p2ren = 128;
    EUSCI_A1.eusciSPI.eusciSPISBSel = EUSCI_A1.eusciSPIDefs.eSPI_MSB_FIRST;
    EUSCI_A1.eusciSPI.eusciSPIClockPolarity = EUSCI_A1.eusciSPIDefs.eSPI_CLOCKPOLARITY_INACTIVITY_HIGH;
    EUSCI_A1.eusciSPI.eusciSPICustomRate = 1000000;
    Timer0_A3.inClkPin[0] = 0;
    Timer0_A3.showExtClkSource = false;
    Timer0_A3.inputClockToTimer = 8.3;
    Timer0_A3.TACTL.timerMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_A").TIMERA_UP_MODE;
    Comparator_D.compdDividerNumerator0 = 2;
    System.sfrie1Regs.interruptSource[3].interruptHandler = true;
    System.sfrie1Regs.interruptSource[5].interruptHandler = true;
    System.sfrie1Regs.interruptSource[6].interruptHandler = true;
    System.sfrie1Regs.interruptSource[7].interruptHandler = true;
    System.sfrie1Regs.interruptSource[3].interruptEnable = false;
    System.sfrie1Regs.interruptSource[5].interruptEnable = false;
    System.sfrie1Regs.interruptSource[7].interruptEnable = false;
    System.sfrie1Regs.interruptSource[6].interruptEnable = false;
    EUSCI_A0.eusciMode = EUSCI_A0.eusciBaseDefs.UARTMode;
    EUSCI_A0.eusciUART.eusciUARTBaudRate = EUSCI_A0.eusciUARTDefs.BaudRate_4;
    EUSCI_A0.eusciUART.eusciUARTPin[0] = 1;
    EUSCI_A0.eusciUART.eusciUARTPin[1] = 1;
    EUSCI_A0.regs.interruptSource[0].interruptEnable = true;
    EUSCI_A0.regs.interruptSource[0].interruptHandler = true;
    EUSCI_A0.regs.interruptSource[1].interruptHandler = true;
    EUSCI_A0.regs.interruptSource[1].interruptEnable = true;
    Timer0_B3.timerMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer").IntervalMode;
    Timer0_B3.intervalModeActive = true;
    Timer0_B3.compareValue[0] = 9;
    Timer0_B3.regs.interruptSource[1].interruptEnable = false;
    Timer0_B3.regs.interruptSource[1].interruptHandler = true;
    Timer0_B3.intervalModeAdvanced = true;
    Timer0_B3.TBCTL.timerClockSource = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_CLOCKSOURCE_SMCLK;
    Timer0_B3.inputClockToTimer = 24000.0;
    EUSCI_A0.eusciUART.eusciUARTClockSource = EUSCI_A0.eusciUARTDefs.eUART_CLOCKSOURCE_SMCLK;
    Timer2_B3.timerMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer").CaptureMode;
    Timer2_B3.intervalModeAdvanced = true;
    Timer2_B3.TBCTL.timerClockSource = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_CLOCKSOURCE_SMCLK;
    Timer2_B3.inputClockToTimer = 24000.0;
    Timer2_B3.txClkPin[0] = 0;
    Timer2_B3.compareValue[0] = 0;
    Timer2_B3.showExtClkSource = false;
    Timer2_B3.TBCTL.timerCounterLength = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_COUNTER_16BIT;
    Timer2_B3.TBCCTL0.timerCaptureMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_CAPTUREMODE_NO_CAPTURE;
    Timer2_B3.TBCCTL1.timerCaptureMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_CAPTUREMODE_NO_CAPTURE;
    Timer2_B3.TBCCTL2.timerCaptureMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_CAPTUREMODE_RISING_EDGE;
    Timer2_B3.ccInputPin[2] = 0;
    Timer2_B3.captureModeActive = false;
    Timer2_B3.captureSynchronize[2] = true;
    Timer2_B3.regs.interruptSource[2].interruptHandler = false;
    Timer2_B3.regs.interruptSource[0].interruptHandler = false;
    Timer2_B3.regs.interruptSource[3].interruptHandler = false;
    EUSCI_B0.eusciMode = EUSCI_B0.eusciBaseDefs.SPIMode;
    EUSCI_B0.eusciSPI.eusciSPIPin[0] = 1;
    EUSCI_B0.eusciSPI.eusciSPIMode = EUSCI_B0.eusciSPIDefs.SlaveMode_3Wire;
    EUSCI_B0.eusciSPI.eusciSPIBitRate = EUSCI_B0.eusciSPIDefs.SPIBitRate_Custom;
    Timer0_B3.TBCTL.timerCounterLength = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_COUNTER_16BIT;
    EUSCI_B0.eusciSPI.eusciSPISBSel = EUSCI_B0.eusciSPIDefs.eSPI_MSB_FIRST;
    EUSCI_B0.eusciSPI.eusciSPIClockPolarity = EUSCI_B0.eusciSPIDefs.eSPI_CLOCKPOLARITY_INACTIVITY_HIGH;
    EUSCI_B0.regs.interruptSource[1].interruptEnable = false;
    EUSCI_B0.regs.interruptSource[1].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[2].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[3].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[4].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[5].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[6].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[7].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[8].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[9].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[10].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[11].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[12].interruptHandler = true;
    EUSCI_B0.regs.interruptSource[0].interruptHandler = true;
    EUSCI_B0.eusciSPI.eusciSPIPin[2] = 1;
    EUSCI_B0.eusciSPI.eusciSPIPin[1] = 1;
    PinMux.regs.pjdir = 15;
    Timer0_A3.inputClockToTimer = 32.768;
    Timer0_A3.regs.interruptSource[0].interruptHandler = true;
    PMM.pmmEnSVSH = false;
    EUSCI_A1.eusciSPI.eusciSPIClockPhase = EUSCI_A1.eusciSPIDefs.eSPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT;
    PinMux.regs.p2dir = 8;
    Timer0_B3.TBCTL.timerClockSourceDivider = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_B").TIMERB_CLOCKSOURCE_DIVIDER_24;
    Timer1_A3.timerMode = xdc.module("ti.mcu.msp430.csl2.timer.ITimer").IntervalMode;
    Timer1_A3.intervalModeActive = true;
    Timer1_A3.compareValue[0] = 101;
    Timer1_A3.regs.interruptSource[1].interruptEnable = true;
    Timer1_A3.regs.interruptSource[1].interruptHandler = true;
    Timer1_A3.intervalModeAdvanced = true;
    Timer1_A3.TACTL.timerClockSourceDivider = xdc.module("ti.mcu.msp430.csl2.timer.ITimer_A").TIMERA_CLOCKSOURCE_DIVIDER_64;
    Timer1_A3.regs.interruptSource[0].interruptHandler = true;
    Timer1_A3.regs.interruptSource[2].interruptHandler = true;
    Timer1_A3.regs.interruptSource[3].interruptHandler = true;
    CS.clockMode = CS.baseDefs.ClockConfigMode;
    CS.csDcoRangeSel = CS.CS_DCORSEL_1;
    CS.csMclkSrcDivider = CS.CS_CLOCK_DIVIDER_1;
    CS.regs.XT1CLKHz = 32768.0;
    CS.csXt1Drive = CS.XT1DRIVE_0;
    CS.csAclkSource = CS.CS_XT1CLK_SELECT;
    Timer1_A3.inputClockToTimer = 32.768;
    var Timer1_B3 = xdc.module('ti.mcu.msp430.csl2.timer.Timer1_B3');
    Timer1_B3.inputClockToTimer = 32.768;
    PinMux.assignedPins = "P1.0 GPIO,P1.1 GPIO,P1.2 GPIO,P1.4 GPIO,P1.5 GPIO,P1.6 EUSCI_B0_SPI,P1.7 EUSCI_B0_SPI,P2.0 EUSCI_A0_UART,P2.1 EUSCI_A0_UART,P2.2 EUSCI_B0_SPI,P2.3 GPIO,P2.4 EUSCI_A1_SPI,P2.5 EUSCI_A1_SPI,P2.6 EUSCI_A1_SPI,P2.7 GPIO,P3.0 GPIO,P3.1 comparator,P3.3 GPIO,P3.4 GPIO,P3.5 CDOUT,P3.6 GPIO,P3.7 GPIO,P4.0 GPIO,P4.1 GPIO,PJ.0 GPIO,PJ.1 GPIO,PJ.2 GPIO,PJ.3 GPIO,PJ.4 XIN,PJ.5 XOUT";
    WDT_A.watchdogMode = WDT_A.WatchdogMode;
    WDT_A.wdtClkSelect = WDT_A.WDT_CLOCKSOURCE_ACLK;
    WDT_A.wdtClkDivider = WDT_A.WDT_CLOCKDIVIDER_512K;
    Timer0_A3.intervalDesiredPeriod = 100;
    Timer0_A3.pwmDesiredFrequency = 10.0;
    Timer1_A3.intervalDesiredPeriod = 200.0;
    Timer1_A3.pwmDesiredFrequency = 5.0;
    CS.csSmclkSrcDivider = CS.CS_CLOCK_DIVIDER_1;
    Timer0_B3.intervalDesiredPeriod = 0.01;
    Timer0_B3.pwmDesiredFrequency = 100000.0;
    Comparator_D.compdEnable = false;

  • This is a bug. It has been submitted and will be fixed in Grace 3.00.01

    [Bug 3023] PxOUT register not being modified when GPIO Pull-Up/Down Resistor Enable is modified

    Can you give me a specific description of what's being lost for GPIO?

    Regards,

    Joe

  • Joe,

    All the PxOUT= statements I expect in  Pinnux_graceinit() are missing.  I have added them into the User segment as a workaround. 

    Do you have an ETA for Grace 3.00.01?

  • Mike,

    I'd like to back up a little and understand your use case. Reviewing the cfg script you posted, no PxOUT registers are set to a non-zero value.

    What are you manually setting the PxOUT values to in PinMux_graceInit()?


    Thanks,

    Joe

  • I ran across this because Grace 2 explicitly wrote the output values zero AND on the MSP430FR5739, if you do not write them , they apperently do not default to zero.  So even though Grace_init is the first line in main(), with 3.0  I had outputs  high.  If you read the comments in PinMux_init.c, it is clear that seven registers should be set in a specific order, starting with PxOUT, but 3.0 never does it, presumably because it assumes they are be zero.  Indeed, if I configure any port pin high it includes a line in PinMux_init.c that will set the whole port.  I am saying that line should always be there. 

  • Thank you for clarifying. This is an instance of  [Bug 3019] Unused GPIO registers are not being initialized. All registers must be set in the initialization function, even if they are zero.

    We're hoping to get Grace 3.00.01 out before the end of next month.  If this is too urgent to wait that long, we can aim for a “snap” update in the next couple of weeks…

    Regards,

    Joe

  • OK thanks. The workaround is easy, just set them in the User code section. So I'll wait for the update.