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.

Please Help!: eZ430-RF2500 simple peer to peer application

Other Parts Discussed in Thread: SIMPLICITI

Hello,

Can anyone PLEASE help me out on the simple peer to peer application supplied with the simpliciTI.

I was able to burn the program into both the target boards(Link to and Link listen) using the IAR  IDE.

I then followed the steps to set-up the peer to peer connection from the sample applications users guide.

After downloading the program into the target boards, the two LEDs light up on both the boards (as mentioned in the users guide),

I then press the push button on the listener to initiate LinkListen. After this, only the red LED switches-ON on the listner. (This is again as mentioned in the users guide)

I then press the push button on the linkTo target board  (where it is SUPPOSED to establish a link with the listener and periodically send and receive 2 byte messages). But, the link does not establish and both the LEDs on the LinkTo device starts blinking thereby indicating that the link was unsuccessful.

I REALLY need help on how to go about this problem so that I can build a chat application as my final project which is due by the end of the next week.

 

I would greatly appreciate your valuable inputs.

 

Thanks,

Jim

  • The most likely cause of failure here is the radio addresses are the same.  Have you made sure the code on the two radios have distinct addresses?  Also, make sure to rebuild all for both builds.  There are dependency issues which don't always get properly managed by the project make file for some reason.

    Jim Noxon

  • okay!

     

    I found your reply from another thread saying:

    "From what I can tell, there is no reason the code should not be working so the next issue I would take a look at is the addresses of the radios.  Each radio's address must be different for the link to succeed.  Since you have done some modifications, is it possible you are using the same .dat file for both compiles?  The .dat file is where you will set the radio address."

     

    Now, I checked the .dat files.

    There are two of them, namely:

    smpl_config.dat

    and 

    smpl_nwk_config.dat

     

    in the smpl_config.dat file, there is a reference to -DTHIS_DEVICE_ADDRESS="{0x79, 0x56, 0x34, 0x12}"

    since the first byte (0x79) is used for the filter, I will let it remain the same in the LinkTo device.

    And in the LinkListen device, I changed this value to 0x12 (ie., I replaced 0x79 by 0x12)

    The link has now been established and the devices are running fine!

     

    Now, with slight modification to the simple peer to peer code,

    I have encountered a problem problem while running the code below.

    The compiler fails to compile the code returning an error saying that "USCI0RX_ISR" (marked red in the code below) is an unknown prototype.

    Can you please suggest what other alternative I could use to get this code working?

    Thanks,

    Jim

    Heres the modified LinkTo code:

     

    #include "bsp.h"

    #include "mrfi.h"

    #include "nwk_types.h"

    #include "nwk_api.h"

    #include "bsp_leds.h"

    #include "bsp_buttons.h"


    smplStatus_t STATUS;

    static uint8_t  sRxTid;

    static linkID_t sLinkID1;

    static uint8_t sRxCallback(linkID_t);

    static volatile uint8_t  sSemaphore;

    #define SPIN_ABOUT_A_SECOND  NWK_DELAY(1000)

    #define DELAY  NWK_DELAY(100)


    void DisplayCharacter(char[], char);

    void KeyPressEnable(void);

    static void linkTo(void);

    volatile char Temp_Size, Temp_General=0;

    void tx_char(uint8_t *, int*);

    void rx_char(void);


    char Key_Not_Pressed, TxHold = 1;

    char Key, txing = 0;

    char Buffer[50] = {0};

    char name[11] = "Jim: ";

    int new_msg, entering_name = 1;


    void main (void){

      BSP_Init();

      SMPL_Init(sRxCallback);

      KeyPressEnable();

      char opening_msg[]= "press key to link\r\n\r\n "; 

      Temp_Size = sizeof(opening_msg);

      DisplayCharacter(opening_msg, Temp_Size);

      while((Key_Not_Pressed));

      linkTo();

      while (1);

    }


    static void linkTo(){

      

      uint8_t  msg[2], tid, rxmsg[2] = 0;

      

      while (SMPL_SUCCESS != SMPL_Link(&sLinkID1))

      {

        SPIN_ABOUT_A_SECOND;

      }

      char array[]= "CONNECTED - Link To\r\n\r\n"; // Connection Established, display msg to hyperterminal

      Temp_Size = sizeof(array);

      DisplayCharacter(array, Temp_Size);

      SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);

      int count = 0;

      KeyPressEnable();

      int * countptr;

      countptr = &count;

      uint8_t* char_var;

      char_var = &msg[0];

      DELAY;


      

      while (1)

      {

        tx_char(char_var, countptr); // Transmit

        

        if (sSemaphore)

        {

          *(rxmsg+1) = ++tid;

          SMPL_Send(sLinkID1, rxmsg, 2);

          /* Reset semaphore. This is not properly protected and there is a race

          * 

          */

          sSemaphore = 0;

        }

      }

    }


    void tx_char(uint8_t  *msg_ptr, int *count){

      uint8_t tid, rxmsg[2]=0;

      

        while((Key_Not_Pressed));  //Wait for a key press from the user

      if( *count >35){ TxHold = 0;

      //wait_message = 1;

      }


      Buffer[*count] = Key;

      (*count)++;

      if (*count == 1){

        int Temp_Size = sizeof(name);

        DisplayCharacter(name, Temp_Size);

      }

      char array[1]= {Key};

      DisplayCharacter(array, 1);

      

      if (sSemaphore)

      {

        *(rxmsg+1) = ++tid;

        SMPL_Send(sLinkID1, rxmsg, 2);

        sSemaphore = 0;

      }

      

      if (!TxHold){

        Buffer[*count] = 0x12;

        char queue[1];

        for(int j=0; j<10; j++){

        queue[0] = name[j];

        SMPL_Send(sLinkID1, queue, 2);}

        for(int i=0; i< *count; i++)

        { 

          msg_ptr[0] = Buffer[i];

          SMPL_Send(sLinkID1, msg_ptr, 2);

        }

        new_msg = 0;

        char array5[]= "\r\n";

        int Temp_Size = sizeof(array5);

        DisplayCharacter(array5, Temp_Size);

        TxHold=1;

        *count=0;

      }

      

      Key_Not_Pressed = 1;

        

    }


    /* handle received frames. */

    static uint8_t sRxCallback(linkID_t port){ 

      uint8_t msg[2], len, tid;

      if (port == sLinkID1)

      {

        if ((SMPL_SUCCESS == SMPL_Receive(sLinkID1, msg, &len)) && len)

        {         

            if(msg[0] == 0x0D){ 

              new_msg = 1;

            char array2[]= "\r\n\r\n";

            Temp_Size = sizeof(array2);

            DisplayCharacter(array2, Temp_Size);

          }

          if(msg[0]< 0x80)

            DisplayCharacter(msg, 1);

          /* Check the application sequence number to detect

          * late or missing frames*/

          

          tid = *(msg+1);

          if (tid)

          {

            if (tid > sRxTid)

            {

              sRxTid = tid;

            }

          }

          else

          {

            /* wrap case */

            if (sRxTid)

            {

              sRxTid = tid;

            }

          }

          sSemaphore = 1;

          

          return 1;

        }

      }

      return 0;

      

    }


    void DisplayCharacter(char array[], char size){

      

      _DINT();

      P3SEL |= 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD

      UCA0CTL1 |= UCSSEL_2;                     // SMCLK

      UCA0BR0 = 0x41;                            // 8MHz 9600

      UCA0BR1 = 0x03;                              // 8MHz 9600

      UCA0MCTL = UCBRS1;                        // Modulation UCBRSx = 2

      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**

      for(int count=0; count<size; count++){

        while (!(IFG2&UCA0TXIFG));                // USCI_A0 TX buffer ready?

        UCA0TXBUF = array[count];                    // TX -> RXed character

        _EINT();

      }

    }



    void KeyPressEnable(void){ 

      UCA0CTL1 |= UCSWRST;                       // Reset State Machine

      UCA0CTL1 &= ~UCSWRST;                      // Initialize USCI Ch. A for key P

      P3SEL |= 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD

      UCA0CTL1 |= UCSSEL_2;                      // SMCLK

      UCA0BR0 = 0x41;                            // 8MHz / 9600

      UCA0BR1 = 0x03;                            // 8MHz / 9600 = 1041.6

      UCA0MCTL = UCBRS1;                         // Modulation UCBRSx = 1

      UCA0CTL1 &= ~UCSWRST;                      // **Initialize USCI state machine**

      IE2 |= UCA0RXIE;                           // Enable USCI_A0 RX interrupt

    }


    //  Echo back RXed character, confirm TX buffer is ready first

    #pragma vector=USCIAB0RX_VECTOR

    __interrupt void USCI0RX_ISR(void){ 

      

      Key_Not_Pressed = 0;


      Key = UCA0RXBUF;

      if(Key == 0x0D)

      { 

        //we've rx'ed a return, transmit all that's in the buffer

        TxHold = 0;

      }

    }

  • So this error occurs because the project settings are set to require prototypes.  You can eliminate this error by turning off the option in the project options dialog or you can simply supply a prototype ahead of the ISR function like this

    Jim Draco said:

    #pragma vector=USCIAB0RX_VECTOR
    __interrupt void USCI0RX_ISR(void);
    #pragma vector=USCIAB0RX_VECTOR
    __interrupt void USCI0RX_ISR(void){ 
      Key_Not_Pressed = 0;
      Key = UCA0RXBUF;
      if(Key == 0x0D)
      { 
        //we've rx'ed a return, transmit all that's in the buffer
        TxHold = 0;
      }
    }

    Personally I would keep the prototypes required option on as it can save you headaches in other places.  It does make ISR functions a bit obtuse but you have to pick your battles wisely, right?

    This should fix this problem.

    Jim Noxon

  • Hey Jim Draco,

     

    I followed the procedures you posted here to check  p2p communication sample. 

    I have also changed the device address as per your suggetion but it didn't work. On one of the boards I downloaded LinkTo and LinkListen on the other. 

    I made change for address for LinkListen device(0x79 to 0x12)  and left 0x79 on the other(LinkTo).

    LinkTo device keep blinking both LEDS which shows that the link is unsuccessful and on the other device(LinkListen) Red led kept On. 

     

    Is there any change that you have made to work it out. Please let me know.

     

    regards,

  • Hi, I hvae the same error

    Error[Pa045]: function "USCI0RX_ISR" has no prototype

    And I can´t fix

    Please I need help

**Attention** This is a public forum