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.

need help for MSP430 timer

Other Parts Discussed in Thread: MSP430F2013, MSP430FG4618, MSP430F2618, CC2500, CC2520

Hello,

I am new to this embedded system, i have experience of windows programming but not with embedded systems. Currently i am using MSP430 exp boards and slac141 code file. I want to implement a communication scenario between two devices in a time strict manner. That their channel time has some predetermined time and the communication between both the devices can occur in that time phase moreover when Tx transmit, the Rx on syn word can generate an interrupt.  I have few questions that

do i need to define a Syn_word for my communication, or isnt already been define in my_rfsettings.h at MDMCFG2 = 0x73.

the most important thing how i can detect a syn word on Rx?

I know maybe these questions are very simple for many of you but i am still new in this field, so sorry for my lack of knowledge.

Your advice and help would be highly appreciateable.

Best Regards

 

 

  • I'm not quite clear on what information you are looking for.

    What MSP430 device is targeted on the experimenter board?  Is it the MSP430FG4618 or the MSP430F2013?

    Which code example are you starting with?  I would suggest you start with the C examples and not the assembly examples which are used in slac141.  The C examples are found in slac080 which can be found on the following Product Folder.
    http://focus.ti.com/docs/prod/folders/print/msp430f2013.html

     

    Regarding the type of communication interface between the devices, are you looking for a master-slave type interface, or a peer-to-peer?

    I'm also not quite clear on the strict time slot requirement.  Would you be able to explain this further?

  • Hello BrandonAzbell,

    Thank you for replying. I am using  MSP430FG4618 and i am working with swra141 C link test example.  The communication interface i am looking for is a master-slave where my master device is always in Tx and  salve Rx in receive. Let me explain my scenario a littile bit. I am trying to build a scenario where a channel or frequency has a time limit, so if in future i can add more slots (tx or rx) in one channel. On my rx device i want to generate a time interrupt on Sync word reception, so i can know the actual communication or arrival of my packet.  The raw output of my logic is as following

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

       Tx

    while (ftime != mytime) //time in msec

         {

             Set tx mode;

              start transmission;

             mytime++; 

    }

    Rx

     while(ftime != mytime)

      {

        set Rx mode;

       if(sync_word)

         { 

            generate an interrupt;

          

        } 

      }

    For the time purpose i am using the function from timer.c

    void halTimerInit(uint16 rate)
    {
        uint16 clock_divider = ID_0; // Default - don't divide input clock

        // rate in usec (time between timer interrupt)
        // The timer input clock is SMCLK @ 4 MHz
        // For 1 usec, the timer must count to 4 (approx)

        if (rate >= 16384)
            clock_divider = ID_2; // divide input clock with 4
        else
            rate <<= 2;            // multiply rate by 4

        // Set compare value
        TACCR0 = rate;

        // Compare mode, clear interrupt pending flag, disable interrupt
        TACCTL0 = 0;

        // Timer source SMCLK
        // Use calculated divider
        // Count up to TACCR0
        // Clear timer
        mode = TASSEL_2 | clock_divider | MC_1 | TACLR;
        TACTL = mode;
    }

    For the timer interrupt, i am using this example framework with my own global variable to check the channel timing.

    #pragma vector=TIMERA0_VECTOR
    __interrupt void timera0_ISR(void)
    {
            ftime++;

        //__low_power_mode_off_on_exit();
    }

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    Currently i am unable to solve the sync word mystery as how to play with it and how to recoganize it. Should i enable it or is it already enable. If yes than how to detect it? Waiting for your reply.

    I need ideas only and the rest i ll try to acheive with my best efforts.

    Best Regards

    RFeng

  • Using the serial interfaces on the MSP430F2618, there is no automatic sync byte transmitted, therefore this is a sync byte that you would need to explicitly send in your master device transmit routine.

    On the slave device, a reception of this byte could generate an interrupt which could provid you the detection of the sync byte.  How you flag that to the rest of your slave software is up to you.

    Does this make sense?

  • Hello BrandonAzbell,

    Thank you for replying, i am sorry to say that your answer made more confuse. Because after reading the CC2500 data sheet and SW code, i have presumed that Sync word is a hardware feature and can be set through register settings and automatically transmitted. As in CC2500 data sheet its been written that "The sync word and preamble are automatically inserted in Tx and removed and processed at Rx" further in configuration register setting the register  0x12 MDMCFG2 bit 2:0 is Sync_Mode. The code http://www-s.ti.com/sc/techlit/swra141 (SW141 link example ) which i am using has MDMCFG2 register setting= 0x73.

    After reading your post i have also tried to set the Sync0 and 1 register but everytime an error occurs guees the register values are not allowed to set, then i mount my radio module on CC2520 Dk and tried to set and export register settings through SmartRf register setting but the output .h file had no entry for Sync1 nd 0 register. 

    The example code packet receiving (Rx mode).

    // Set radio in RX mode
        halRfStrobe(CC2500_SRX);

        // Wait for incoming packet "The possible point for sync word detetction"
        key = halIntLock();
        while(!packetReceived)
        {
            halMcuSetLowPowerMode(HAL_MCU_LPM_3);
            key = halIntLock();
        }
        halIntUnlock(key)

    Kindly guide me to come out from this confusion as it is a very simple thing and i am unable to solve.

    BR

    RFeng

     

  • Yes, I agree, I was confused and created confusion.  When I read your post, I interpreted your comments to refer to the SPI interface, or serial interface on the device and not to RF side.
    Now I see and apologize for creating confusion.

    I will need to take another look at your posts.  Sorry about that.

  • Are you targeting the CC2500 or CC2520?  The reason I ask is based on your reference to the CC2520 DK.  Are you placing the CC2500EM on the SmartRF05EB + CCMSP-EM430F2618 platform?

  • Hello BrandonAzbell,

    I am targeting CC2500 and i am using SmartRf04EB. So i am placing CC2500 EM on SmartRf04EB platform, to generate a CC2500.h register settings. File ->ExportCC2500code->Rf Setings.

  • Hello BrandonAzbell,

    I guess i am making you confuse, i am sorry for the inconvenience. Let me explain what i am trying to do in some detail. 

    in advance i am sorry for mylittle knowledge. I am using MSP430FG4618 exp boards with CC2500 em mounted. The example code on which i am working is http://www- (SW141 link example). I am trying to build an echo or ping pong example and struck on preamble and sync word. My confusion is that should i construct a packet = preamble byte + sync word + length byte + payload + extra byte or is already done through hardware (preamble + sync word) register settings? According to my assumption after reading CC2500's data sheet "The sync word and preamble are automatically inserted in Tx and removed and processed at Rx". Further CC2500'c 0x12: MDMCFG2 register is already set for 30/32 sync word bits and 0x13: MDMCFG1 is set for 4
    byte preamble, and i am setting sync 1 and sync 0
    halRfWriteReg(CC2500_SYNC1, 0x73); // Set Sync1 word
    halRfWriteReg(CC2500_SYNC0, 0x73); // set sync0 word

    The code for packet construction is as following.
    ----------------------------------------------------------------------
    static void preparePacket(uint8 id, uint8* data, uint8* length)
    {
    uint8 i;
    static uint8 payloadLength;

    payloadLength++;
    if (payloadLength > 61)
    payloadLength = 10;

    // First byte of packet contains the length of the payload
    data[0] = payloadLength;

    // First byte of payload contains an id
    data[1] = id;


    // Fill rest of packet with dummy data
    for (i = 2; i <= payloadLength; i++)
    data[i] = i;

    // Packet length is payload + length byte
    *length = payloadLength + 1;
    }
    -------------------------------------------------------------
    Now i am bit confused here that what should i do?s.ti.com/sc/techlit/swra141


    By setting the above mentoined register setting for preamble and sync word they are transmitted when transmitter started?


    Am i following the right path that by only setting register values the preamble and sync word are transmitted, no need to construct a
    packet with these fields ?

    Best Regards

     

  • Thank you for the background as I believe it helps clarify your needs.
    I would refer to Section 15 of the CC2500 datasheet to answer this question about whether the CC2500 automatically adds the preamble, sync word, etc.

    In Section 15, it states the CC2500 packet handler hardware can add the following elements to the packet stored in the TX FIFO.

    • Programmable number of preamble bytes
    • Two byte synchronization (sync) word
    • CRC checksum

     

  • Hello,

    Thank you BrandonAzbell, i dont know why i was so confused on such a simple step (i guess first time with RF). When i check the register setting for all those they are already set, except Sync1 and Sync0 which i have already set. For e.g

    Pktctrl0=0x55 (CRC enabled)

      0x73,   = MDMCFG2 // Sync word
      0x22,   = MDMCFG1 // Preamble

    So now i am on to next phase of Generating timer interrupts (God help me).

    Once again thanx for your time and patience.

     

    Best Regards

     

     

**Attention** This is a public forum