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.

PxOUT and PxSEL initialisation

Other Parts Discussed in Thread: MSP430G2432

I recently switched from an older version (don't remember which) to CCS  5.1.0.09000 on windows 7.

I ran in to trouble with one old program because the chip started to pull some pins high (program wasn't changed)

I used Grace in the old CCS version, and I am using the built in version of CCS  5.1.0.09000

Using the debugger I discovered that P2OUT is apparently initialized at a value of "1011111" after reset.

In the old version I also noticed that P2SEL was initialized at "11000000"

Is it necessary to initialize this at the beginning of each program? In Grace these registers are set to 0 , so why does grace not take care of this initialization if needed?

Are there any other changes like this that I can expect?

This application drives a high power switch, so any sudden changes in behavior could be dangerous.

  • Hello Bart,

    Backwards compatibility with older Grace versions is an absolute must have. You should be able to seamlessly upgrade your existing installation. I am sorry that you ran into problems after your update and will try my best to analyze the issue that is causing this.

    Can you provide us with more information? What device are you using? Can you send us the project, or at least the .cfg file?

    Thanks and Regards,

    Michael 

  • Hello Michael,

    The problem is not only the non-backwards compatibility, but also the strange initialisation values for P2OUT (I am using it to set pull up-/down on port2) and P2SEL.

    In Grace these values ar shown to be 0, but in the debugger they have different values. I fixed this by manually initializing them to 0 in the beginning of the program though.

    The chip I am using is MSP430G2432.

    Previous version of grace was grace_1_00_01_83 (installed seperately)

    current and old .cfg are below (cannot attach)

    OLD:

    /* need to use the CSL module to generate the CSL code */
    var CSL = xdc.useModule('ti.mcu.msp430.csl.CSL');
    var ADC10 = xdc.useModule('ti.mcu.msp430.csl.adc.ADC10');
    var Timer0_A3 = xdc.useModule('ti.mcu.msp430.csl.timer.Timer0_A3');
    var WDTplus = xdc.useModule('ti.mcu.msp430.csl.watchdog.WDTplus');
    CSL.configApiVersion = "1.00.00";
    var GPIO = xdc.useModule('ti.mcu.msp430.csl.gpio.GPIO');
    var BCSplus = xdc.useModule('ti.mcu.msp430.csl.clock.BCSplus');
    var System = xdc.useModule('ti.mcu.msp430.csl.system.System');

    /* set stack and heap sizes as appropriate for MSP430 */
    Program.sysStack = 0;
    Program.stack = 64;
    Program.heap = 0;
    Program.argSize = 0;
    CSL.device.vcc = 2.5;
    GPIO.regs.P1DIR.Bit0 = GPIO.defs.BIT0;
    GPIO.regs.P1DIR.Bit1 = GPIO.defs.BIT1;
    GPIO.regs.P1DIR.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P1DIR.Bit3 = GPIO.defs.BIT3_OFF;
    GPIO.regs.P1DIR.Bit5 = GPIO.defs.BIT5;
    GPIO.regs.P2DIR.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2SEL.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2SEL.Bit7 = GPIO.defs.BIT7_OFF;
    GPIO.regs.P2DIR.Bit5 = GPIO.defs.BIT5_OFF;
    ADC10.channelEnablePowerUser.chan7 = true;
    ADC10.regs.ADC10CTL0.ADC10ON = ADC10.defs.ADC10ON;
    ADC10.regs.ADC10CTL1.INCH = ADC10.defs.INCH_7;
    ADC10.maxSignalBandwidth = 0;
    ADC10.regs.ADC10CTL0.ADC10SR = ADC10.defs.ADC10SR;
    ADC10.regs.ADC10CTL1.SHS = ADC10.defs.SHS_0;
    ADC10.regs.ADC10CTL0.ADC10IE = ADC10.defs.ADC10IE;
    ADC10.adc10Handler = "adcIsr";
    ADC10.adc10OperatingModeOnExit = ADC10.ACTIVE;
    ADC10.regs.ADC10CTL0.REF2_5V = ADC10.defs.REF2_5V_OFF;
    ADC10.regs.ADC10CTL0.REFON = ADC10.defs.REFON;
    ADC10.regs.ADC10CTL0.SREF = ADC10.defs.SREF_1;
    ADC10.regs.ADC10CTL1.ADC10DIV = ADC10.defs.ADC10DIV_3;
    ADC10.regs.ADC10CTL0.ADC10SHT = ADC10.defs.ADC10SHT_3;
    ADC10.regs.ADC10AE0 = 128;
    GPIO.regs.P2IFG.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2IES.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2IE.Bit4 = GPIO.defs.BIT4;
    GPIO.port2IntHandler = "P2Isr";
    GPIO.port2OperatingModeOnExit = GPIO.ACTIVE;
    GPIO.regs.P2REN.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2OUT.Bit4 = GPIO.defs.BIT4_OFF;
    Timer0_A3.ccr0TimerSelection_BasicView = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCR0TimerSelection_BasicView_Selection_1;
    Timer0_A3.ccr0TimerSelection_PowerUser = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCR0TimerSelection_PowerUser_Selection_1;
    Timer0_A3.ccInputPin[0] = 0;
    Timer0_A3.regs.TA0CTL.MC = Timer0_A3.defs.MC_1;
    Timer0_A3.regs.TA0CCR0 = 0;
    Timer0_A3.regs.TA0CTL.TASSEL = Timer0_A3.defs.TASSEL_1;
    Timer0_A3.inputClockToTimer = 12.0;
    Timer0_A3.regs.TA0CCTL0.CCIE = Timer0_A3.defs.CCIE;
    Timer0_A3.ccr0InterruptHandler = "timerIsr";
    Timer0_A3.ccr0OperatingModeOnExit = xdc.module("ti.mcu.msp430.csl.timer.ITimer").ACTIVE;
    Timer0_A3.ccrXTimerSelection_PowerUser[1] = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCRxTimerSelection_PowerUser_Selection_0;
    Timer0_A3.ccInputPin[2] = 0;
    Timer0_A3.ccrXTimerSelection_BasicView[1] = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCRxTimerSelection_BasicView_Selection_0;
    Timer0_A3.ccrOutputPin[2] = 0;
    Timer0_A3.regs.TA0CCR1 = 0;
    Timer0_A3.regs.TA0CTL.ID = Timer0_A3.defs.ID_2;
    GPIO.regs.P2OUT.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P2IES.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P2IE.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P2REN.Bit2 = GPIO.defs.BIT2;
    GPIO.regs.P1REN.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P1IE.Bit2 = GPIO.defs.BIT2;
    GPIO.regs.P1IES.Bit2 = GPIO.defs.BIT2;
    GPIO.regs.P1OUT.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.port1IntHandler = "P1Isr";
    GPIO.regs.P1DIR.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.port1OperatingModeOnExit = GPIO.ACTIVE;
    GPIO.regs.P1REN.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P1IE.Bit4 = GPIO.defs.BIT4;
    GPIO.regs.P1IES.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P1OUT.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2OUT.Bit1 = GPIO.defs.BIT1_OFF;
    GPIO.regs.P2DIR.Bit1 = GPIO.defs.BIT1_OFF;
    GPIO.regs.P2REN.Bit1 = GPIO.defs.BIT1;
    GPIO.regs.P2IES.Bit1 = GPIO.defs.BIT1_OFF;
    GPIO.regs.P2IES.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2IE.Bit6 = GPIO.defs.BIT6;
    GPIO.regs.P2IE.Bit5 = GPIO.defs.BIT5;
    GPIO.regs.P2REN.Bit5 = GPIO.defs.BIT5;
    GPIO.regs.P2REN.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2IE.Bit0 = GPIO.defs.BIT0;
    GPIO.regs.P2REN.Bit0 = GPIO.defs.BIT0;
    GPIO.regs.P2IE.Bit7 = GPIO.defs.BIT7;
    GPIO.regs.P2REN.Bit7 = GPIO.defs.BIT7;
    GPIO.regs.P1IES.Bit3 = GPIO.defs.BIT3_OFF;
    GPIO.regs.P2IES.Bit0 = GPIO.defs.BIT0_OFF;
    GPIO.regs.P2IE.Bit1 = GPIO.defs.BIT1;
    GPIO.regs.P2OUT.Bit7 = GPIO.defs.BIT7_OFF;
    System.ie1Regs.IE1.WDTIE = System.ie1Defs.WDTIE_OFF;
    GPIO.regs.P2IES.Bit7 = GPIO.defs.BIT7_OFF;
    GPIO.regs.P2IFG.Bit7 = GPIO.defs.BIT7_OFF;
    GPIO.regs.P2SEL.Bit0 = GPIO.defs.BIT0_OFF;
    GPIO.regs.P2REN.Bit3 = GPIO.defs.BIT3;
    WDTplus.regs.WDTCTL.WDTHOLD = WDTplus.defs.WDTHOLD_OFF;
    WDTplus.regs.WDTCTL.WDTSSEL = WDTplus.defs.WDTSSEL;
    WDTplus.regs.WDTCTL.WDTTMSEL = WDTplus.defs.WDTTMSEL;
    WDTplus.wdtHandler = "whatchdogIsr";

    NEW:

    /* need to use the CSL module to generate the CSL code */
    var CSL = xdc.useModule('ti.mcu.msp430.csl.CSL');
    var ADC10 = xdc.useModule('ti.mcu.msp430.csl.adc.ADC10');
    var Timer0_A3 = xdc.useModule('ti.mcu.msp430.csl.timer.Timer0_A3');
    var WDTplus = xdc.useModule('ti.mcu.msp430.csl.watchdog.WDTplus');
    CSL.configApiVersion = "1.00.00";
    var GPIO = xdc.useModule('ti.mcu.msp430.csl.gpio.GPIO');
    var BCSplus = xdc.useModule('ti.mcu.msp430.csl.clock.BCSplus');
    var System = xdc.useModule('ti.mcu.msp430.csl.system.System');

    /* set stack and heap sizes as appropriate for MSP430 */
    Program.sysStack = 0;
    Program.stack = 64;
    Program.heap = 0;
    Program.argSize = 0;
    CSL.device.vcc = 2.5;
    GPIO.regs.P1DIR.Bit0 = GPIO.defs.BIT0;
    GPIO.regs.P1DIR.Bit1 = GPIO.defs.BIT1;
    GPIO.regs.P1DIR.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P1DIR.Bit3 = GPIO.defs.BIT3_OFF;
    GPIO.regs.P1DIR.Bit5 = GPIO.defs.BIT5;
    GPIO.regs.P2DIR.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2SEL.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2SEL.Bit7 = GPIO.defs.BIT7_OFF;
    GPIO.regs.P2DIR.Bit5 = GPIO.defs.BIT5_OFF;
    ADC10.channelEnablePowerUser.chan7 = true;
    ADC10.regs.ADC10CTL0.ADC10ON = ADC10.defs.ADC10ON;
    ADC10.regs.ADC10CTL1.INCH = ADC10.defs.INCH_7;
    ADC10.maxSignalBandwidth = 0;
    ADC10.regs.ADC10CTL0.ADC10SR = ADC10.defs.ADC10SR;
    ADC10.regs.ADC10CTL1.SHS = ADC10.defs.SHS_0;
    ADC10.regs.ADC10CTL0.ADC10IE = ADC10.defs.ADC10IE;
    ADC10.adc10Handler = "adcIsr";
    ADC10.adc10OperatingModeOnExit = ADC10.ACTIVE;
    ADC10.regs.ADC10CTL0.REF2_5V = ADC10.defs.REF2_5V_OFF;
    ADC10.regs.ADC10CTL0.REFON = ADC10.defs.REFON;
    ADC10.regs.ADC10CTL0.SREF = ADC10.defs.SREF_1;
    ADC10.regs.ADC10CTL1.ADC10DIV = ADC10.defs.ADC10DIV_3;
    ADC10.regs.ADC10CTL0.ADC10SHT = ADC10.defs.ADC10SHT_3;
    ADC10.regs.ADC10AE0 = 128;
    GPIO.regs.P2IFG.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2IES.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2IE.Bit4 = GPIO.defs.BIT4;
    GPIO.port2IntHandler = "P2Isr";
    GPIO.port2OperatingModeOnExit = GPIO.ACTIVE;
    GPIO.regs.P2REN.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2OUT.Bit4 = GPIO.defs.BIT4_OFF;
    Timer0_A3.ccr0TimerSelection_BasicView = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCR0TimerSelection_BasicView_Selection_1;
    Timer0_A3.ccr0TimerSelection_PowerUser = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCR0TimerSelection_PowerUser_Selection_1;
    Timer0_A3.ccInputPin[0] = 0;
    Timer0_A3.regs.TA0CTL.MC = Timer0_A3.defs.MC_1;
    Timer0_A3.regs.TA0CCR0 = 0;
    Timer0_A3.regs.TA0CTL.TASSEL = Timer0_A3.defs.TASSEL_1;
    Timer0_A3.inputClockToTimer = 12.0;
    Timer0_A3.regs.TA0CCTL0.CCIE = Timer0_A3.defs.CCIE;
    Timer0_A3.ccr0InterruptHandler = "timerIsr";
    Timer0_A3.ccr0OperatingModeOnExit = xdc.module("ti.mcu.msp430.csl.timer.ITimer").ACTIVE;
    Timer0_A3.ccrXTimerSelection_PowerUser[1] = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCRxTimerSelection_PowerUser_Selection_0;
    Timer0_A3.ccInputPin[2] = 0;
    Timer0_A3.ccrXTimerSelection_BasicView[1] = xdc.module("ti.mcu.msp430.csl.timer.ITimer").CCRxTimerSelection_BasicView_Selection_0;
    Timer0_A3.ccrOutputPin[2] = 0;
    Timer0_A3.regs.TA0CCR1 = 0;
    Timer0_A3.regs.TA0CTL.ID = Timer0_A3.defs.ID_2;
    GPIO.regs.P2OUT.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P2IES.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P2IE.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P2REN.Bit2 = GPIO.defs.BIT2;
    GPIO.regs.P1REN.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.regs.P1IE.Bit2 = GPIO.defs.BIT2;
    GPIO.regs.P1IES.Bit2 = GPIO.defs.BIT2;
    GPIO.regs.P1OUT.Bit2 = GPIO.defs.BIT2_OFF;
    GPIO.port1IntHandler = "P1Isr";
    GPIO.regs.P1DIR.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.port1OperatingModeOnExit = GPIO.ACTIVE;
    GPIO.regs.P1REN.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P1IE.Bit4 = GPIO.defs.BIT4;
    GPIO.regs.P1IES.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P1OUT.Bit4 = GPIO.defs.BIT4_OFF;
    GPIO.regs.P2OUT.Bit1 = GPIO.defs.BIT1_OFF;
    GPIO.regs.P2DIR.Bit1 = GPIO.defs.BIT1_OFF;
    GPIO.regs.P2REN.Bit1 = GPIO.defs.BIT1;
    GPIO.regs.P2IES.Bit1 = GPIO.defs.BIT1_OFF;
    GPIO.regs.P2IES.Bit6 = GPIO.defs.BIT6_OFF;
    GPIO.regs.P2IE.Bit6 = GPIO.defs.BIT6;
    GPIO.regs.P2IE.Bit5 = GPIO.defs.BIT5;
    GPIO.regs.P2REN.Bit5 = GPIO.defs.BIT5;
    GPIO.regs.P2REN.Bit6 = GPIO.defs.BIT6;
    GPIO.regs.P2IE.Bit0 = GPIO.defs.BIT0;
    GPIO.regs.P2REN.Bit0 = GPIO.defs.BIT0;
    GPIO.regs.P2IE.Bit7 = GPIO.defs.BIT7;
    GPIO.regs.P2REN.Bit7 = GPIO.defs.BIT7;
    GPIO.regs.P1IES.Bit3 = GPIO.defs.BIT3_OFF;
    GPIO.regs.P2IES.Bit0 = GPIO.defs.BIT0_OFF;
    GPIO.regs.P2IE.Bit1 = GPIO.defs.BIT1;
    GPIO.regs.P2OUT.Bit7 = GPIO.defs.BIT7_OFF;
    System.ie1Regs.IE1.WDTIE = System.ie1Defs.WDTIE_OFF;
    GPIO.regs.P2IES.Bit7 = GPIO.defs.BIT7_OFF;
    GPIO.regs.P2IFG.Bit7 = GPIO.defs.BIT7_OFF;
    GPIO.regs.P2SEL.Bit0 = GPIO.defs.BIT0_OFF;
    GPIO.regs.P2REN.Bit3 = GPIO.defs.BIT3;
    WDTplus.regs.WDTCTL.WDTHOLD = WDTplus.defs.WDTHOLD_OFF;
    WDTplus.regs.WDTCTL.WDTSSEL = WDTplus.defs.WDTSSEL;
    WDTplus.regs.WDTCTL.WDTTMSEL = WDTplus.defs.WDTTMSEL;
    WDTplus.wdtHandler = "whatchdogIsr";




    regards,

    Bart

  • Bart,

    The P2SEL values are the reset values that are mirrored in Grace. Xin and Xout are connecting to an external crystal and are therefore enabled at reset. Grace doesn't do anything about this by default.

    Looking at your settings, it seems that you try to drive your high power switch by using the GPIO resistors and leave the pins at the "input" setting. Is there a reason you don't want to set the pins to output?

    However, you found an issue that needs to be taken care of:  The output register is not being reset to a value, but left unchanged after reset. Grace tries to set as few registers as possible at startup, but in that case, you would want to explicitly set the output register to 0, since you want to set the resistors to pull down. Unfortunately, Grace only sets the output register when the direction is set to output.

    Thanks for giving us this feedback. This bug will be fixed in the next Grace release.

    If you need further assistance, please ask!

    Regards,

    Michael

     

  • Michael,

    Thanks for the fast reply.

    The drivers for the switch are located at pins 0 and 1 of port 1 which are set to output.

    Pin 6 of port 2 is used to drive an alarm LED, It is initially set to input though.

    This is because I didn't have enough pins: after an alarm pulse comes in at this port, it is switched to output, and keeps the LED on.

    Maybe this is wat you meant by "using the GPIO resistors and leave the pins at the "input" setting" ?

    Regards,

    Bart

  • Bart,

    Yes, I looked at port 2 and  found this odd.

     For clarification: you said you have the high power switches at port 1. Did you have problems with these? Since you set port 1 pin 0 and pin 1 to output, everything should be fine.

    Regards,

    Michael 

  • No problems for port 1, only the init problem on port 2, which is now solved with the workerount (init at begin of program).

    Thanks,

    Bart

**Attention** This is a public forum