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.

MSP430F2122 4MHz xtal startup & Pin-toggling

Other Parts Discussed in Thread: MSP430F2122

Hi all,

I am new to MSP.

I have designed my own hardware for MSP430F2122 28-pin micro-controller based on MSP Demo Board

I am using MSP430FET-USB Debugger/Programmer with IAR Embedded Workbench KickStart for MSP430 V4

I am using an example code from TI ti toggle a port pin which is not happening! Furthermore I don't find my device in the Target Options of the IDE.

I have tried without an external Xtal & also with a 4MHz crystal connected to Pins 5 & 6 with 10pF loading capacitors but to no succes!

Urgent help please...

Thanks in advance

-SM85

  • All MSPs have an internal clock generator (DCO - digitally controlled oscillator), so there is no need to use an external crystal to make any program run.
    In fact, you'll need code to activate the usage of an external XTAL (which is of course more precise and stable then).

    So the device should work without any XTAL and with any capacitor settings.

    You write you cannro find the device in the target options. I believe that you then cannot download your code the the device too. Obviously, it cannot run on the device if you didn't download it first :)

    You should first solve the problem of setting the correct target device options (else your code will be compiled for a different memory layout or hardware registers). Then you should ensure that you're downloading the code to the device correctly.

    If your sample code has been taken from a different device, you should adjust the include of the proper msp430xxx.h header (if not already controlled by the project settings).

    You should ensure that your program is running the port pin toggle code properly before you start trying to use an XTAL. If the port pin toggle demo is running, your basic working chain is okay. It does not, however, mean that the clock handling will run, unless you use the correct device settings in the project. The ports used for the example are more or less identical across all MSPs, the handling of the clock module differs, and with incorrect includes or project settings, things won't work.

     

  • Hey thanks,

    I'm happy to inform all that I have started my journey with MSP430.

    Couldn't make things work with IAR so moved on to CCS (code limited edition)

    Successfully configured & used GPIO, Timer & UART Peripherals of MSP430F2122

    I have one question... I have used 4Mhz external Crystal & configured for the same as follows:

    // for crystal 

       BCSCTL1 |= XTS; // ACLK = LFXT1 = HF XTAL

       BCSCTL3 |= LFXT1S1; // 3 – 16MHz crystal or resonator

    do

       {

         IFG1 &= ~OFIFG; // Clear OSCFault flag

         for (i = 0xFF; i > 0; i--); // Time for flag to set

       }

       while (IFG1 & OFIFG); // OSCFault flag still set?

       BCSCTL2 |= SELM_3; // MCLK = LFXT1 (safe)

    //directly from the example!

    But, when I configure Timer & USART by observation I have to put values corresponding to 1MHz. Can anybody explain?

    Say for eg. timer initialization is as follows:

     TA1CCR0 = 999 ; 

    TA1CTL = TASSEL_2 + MC_1 + TAIE;

    Here the reload value should be (4000 - 1) but 999 (1000 - 1) works perfect for 1mili-second interrupt!

    Same applies for Baud rate generator...

    Please share your expertise.

    -SM85

     

  • It looks like ACLK & MCLK are set to your 4MHz xtal. What is SMCLK set to?

    TASSEL_2 chooses SMCLK, not MCLK or ACLK. SMCLK might be set to the default DCO (which by default is 1MHz).

  • Thanks a lot...

    SMCLK is set to default DCO. The following may configure it,

    BCSCTL2 |= SELM_3 + SELS ;                         // MCLK = LFXT1 = SMCLK

    This will set SMCLK = ACLK = MCLK

    Am I right? I have changed to the peripheral clock to ACLK and it is working fine!

    TA1CCR0 = 3999 ; 

    TA1CTL = TASSEL_1 + MC_1 + TAIE;             // ACLK, up cont mode, interrupt enabled

    Best regards,

    -SM85

**Attention** This is a public forum