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.

MSP430FR5969 - Problem with simple code

Other Parts Discussed in Thread: MSP-TS430RGZ48C, MSP430FR5969

Hi all,

I'll show you a simple code. I use MSP430FR5969 Wolverine, MSP-FET430UIF as development kit and board MSP-TS430RGZ48C. This is the code; it was tested with latest versions of CCS and IAR.

#include<msp430.h>

void main()

{

int a=0;

P1DIR |= BIT0;

P1OUT=0;

WDTCTL = WDTPW | WDTHOLD;

while(1)

{

a++;

P1OUT^=BIT0;

__delay_cycles(20000);

}

}

This code works! I can see led blinking and 'a' increases at any step. But if I define 'a' before main as volatile int a=0 (global variable) the led is permanently off. Hence I can't reach main(). Do you know if MSP430FR59xx has problems with global variables?

Thank you.

Fabio

  • Defining "a" as volatile externally to the main is working by my side. For the moment I have some problems with the clock system, and found one chip which won't work at all but from the firmware view it seems to works. But, in an other hand, I'm new by a couple of days on CCS...

    Did you configure the linker  with strange parameters?

  • I've touched nothing about configuration. But do you use the microcontroller MSP430FR5969?

  • Yes I use it in prototype version.

  • So, you have the same code I've posted above (with global variable), no settings changed in CCS and it works. What version of CSS do you use? Could it be a problem of version? Do you have also the same development kit I use?

  • Try adding this function to your code and see if it makes a difference. The watchdog timer can go off while the runtime library is initialising itself even before main() is called. By making "a" global it now needs to be initialised which takes longer before your main gets called and disables the watchdog.

    Normally the problem only shows up with large global arrays but maybe you have a slow processor?

    This function has a special name which is known to the C runtime system and it will be called very early after your program starts. But note: you should do very little in this function as the C runtime system is not yet properly initialised.

    int _system_pre_init(void)
    {
      WDTCTL = WDTPW + WDTHOLD;
      return 1;
    }

  • Did you see the LED blinking with your eyes? The boot frequency of FR5969 is 8Mhz, so 20k cycles delay is only 2.5ms so 400Hz on LED.

    The watchdog is by default 1sec sourced from ACLK, so if you really see the LED Nick is right, it's a watchdog problem.

    I tried your example in my project, so the full system was initialized.

  • Hi Nick, I've tried your solution, but it doesn't work. I'm still unable to reach main....I'm beginning to think that as this samples are still in preview,  some of them could have some problem like this. I hope newer samples to have no problems...

  • Yes, if a is a local variable the led blinks, it's very fast but I can see it. When a is global, led is always off, also using Nick code first of global variable declaration.

  • Could you try to put a breakpoint at the beginning of the main and check if it is reached?

    If it doesn't, then maybe break the code and tell us where it is blocked. Activate disassembly to see exactly.

  • Try this: http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/262643.aspx?pi73866=2

    In fact I also have problem with volatile variables... but not for your example the time I've tested it.

    For example today:

    "volatile unsigned char test=0;
    test=((P1IN&GPIO_PIN2)>>2);"

    Test stay 0x3F... even if the calculation if ok in asm

    With the Chester's DLL it seems to work in a better way, but not sure at this time.

    NEED AN UPDATE FROM TI! :p

  • I already tried debug and main is not reached; optimization is off. This is disassembly:

    $C$L1:

    0046fe: 493C MOV.W @R9+,R12

    004700: 493D MOV.W @R9+,R13

    004702: 0DCF MOVA R13,R15

    004704: 180F 5F4F RPT #16 RLAX.A R15 ---------------------->This is the point where debug blocks.

    004708: 1800 DC4F BISX.A R12,R15

    00470c: 4F6F MOV.B @R15,R15

    00470e: 4F4F MOV.B R15,R15 004710: 065F RLAM.W #2,R15 004712: 1800 4F5B 4408 MOVX.A 0x04408(R15),R11 004718: 531C INC.W R12 00471a: 630D ADC.W R13 00471c: 493E MOV.W @R9+,R14 00471e: 493F MOV.W @R9+,R15 004720: 134B CALLA R11 004722: 831A DEC.W R10 004724: 23EC JNE ($C$L1)

    $C$L2:

  • I tried that DLL yesterday and nothing changed; I think there is also a compatibility problem because it is developed for FR57 I see. In fact with that DLL I had error messages when I loaded code on target. I've just ordered a pair of new MCU Wolverine, hoping better :)

  • Hoping so, even if it seems not logical... As you have problem with IAR too it should not be IDE related... I use v1.4a FET430UIF what on your side?

  • I use FET430UIF v1.4 too. Yes I have same problem with IAR, Debug mode works like in CCS and in non-debug mode led doesn't blink.

  • Fabio Marinosci said:
    I tried that DLL yesterday and nothing changed; I think there is also a compatibility problem because it is developed for FR57 I see. In fact with that DLL I had error messages when I loaded code on target.

    I have attached an updated MSP430.dll to debug variable and expressions windows are empty which I think may fix the same problem on a MSP430FR5969. However, I don't have a MSP430FR5969 so haven't been able to test the fix on that device.

  • I can confirm it is a preview version problem. I tried code above with another MSP430FR5969 and it works perfectly. 

  • How  can  I  Debug 430FRam  by IAR  with FET430UIF  ?

        In   IAR v5.60  , after "Download  and  Debug",    it ".....stop......" , but   how to Debug   it  !

  • Please start a new thread when you have a totally unrelated question.

    Also, please provide more info (in this new thread, not here).

    And don't use large font sizes unless you have a reason. It rather repels people instead of gaining attention.

  • The above code will not work properly, I would like to discuss three points here.

    1 . You have to bring bring out the IO lines out of high Impedance state, once the POR is applied the IO lines will be automatically moved to high impedance state, 

    2. What is the need of a in your code. Without that a, you can toggle the LED,

    3. Your LED blinks very fast with given delay, so increase the delay to some high value.

    Check out the code pasted below,  this works fine for me. 

    #include<msp430fr5969.h>


    void main()

    {

    //int a=0;

    P1DIR |= BIT0;

    P1OUT=0;

    WDTCTL = WDTPW | WDTHOLD;
    PM5CTL0 &= ~LOCKLPM5;

    while(1)

    {
    // int a=0;
    //a++;

    P1OUT^=BIT0;

    __delay_cycles(100000);

    }

    }

**Attention** This is a public forum