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.

SMPL_Init() fails after device address is set

Other Parts Discussed in Thread: SIMPLICITI

Hi all,

I'm using SimpliciTI 1.10 (AP_as_data_hub example based) in which I use the following code to read the pre programmed IEEE address and use it as the device's network adress:

__near_func void MnGetIEEEAddress(unsigned char *a)
{
  unsigned char bank;                                                           // Code is copied from TI example
  bank = MEMCTR;
  // switch to bank 3
  MEMCTR |= 0x30;
  a[0] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 0);
  a[1] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 1);
  a[2] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 2);
  a[3] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 3);
  a[4] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 4);
  a[5] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 5);
  a[6] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 6);
  a[7] = *(unsigned char __code *)(IEEE_ADDRESS_ARRAY + 7);
  // restore old bank settings
  MEMCTR = bank;
}

void MnSetAddress (void)
{
  addr_t  adrAddress;
  uint8_t aIeee[8];
  uint8_t i=0;
 
  MnGetIEEEAddress(aIeee);
  for (i=0; i<NET_ADDR_SIZE; i++)
  {
    adrAddress.addr[i] = aIeee[i];
  }
  SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &adrAddress);
}

This worked fine in SimpliciTI 1.06 but in 1.10 these functions work fine but the SMPL_Init() function returns SMPL_NO_CHANNEL when I use these functions to set the address. If I comment out the call to MnSetAddress in my main() procedure everything works fine...

Can anyone tell me what it is I'm doing wrong?

Ad

  • Hmmm, I seem to have traced the problem to the nwk_globals.c module in which the procedure

    /******************************************************************************
     * @fn          nwk_globalsInit
     *
     * @brief       Initialization of global symbols
     *
     * input parameters
     *
     * output parameters
     *
     * @return   void
     */
    void nwk_globalsInit(void)
    {

      memset(&sAPAddress, 0x00, sizeof(addr_t));
      memset(&sMyRAMAddress, 0x00, sizeof(addr_t));

      /* populate RAM address from ROM default if it hasn't laready been set
       * using the IOCTL interface.
       */
      if (!sRAMAddressIsSet)
      {
        memcpy(&sMyRAMAddress, &sMyROMAddress, sizeof(addr_t));
        sRAMAddressIsSet = 1;  /* RAM address is now valid */
      }

      return;
    }

    clears the MyRAMAddress which was previously set by the SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &adrAddress); call. This procedure is called during the SMPL_Init before which it is specified the SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &adrAddress); must be called if it is to be used. Could this be a bug? I changed the nwk_globalsInit procedure to

    void nwk_globalsInit(void)
    {

      memset(&sAPAddress, 0x00, sizeof(addr_t));
      if (!sRAMAddressIsSet)
      { 
        memset(&sMyRAMAddress, 0x00, sizeof(addr_t));
      }

      /* populate RAM address from ROM default if it hasn't laready been set
       * using the IOCTL interface.
       */
      if (!sRAMAddressIsSet)
      {
        memcpy(&sMyRAMAddress, &sMyROMAddress, sizeof(addr_t));
        sRAMAddressIsSet = 1;  /* RAM address is now valid */
      }

      return;
    }

    Which seems to work. Are there any risks involved with this action?

    Ad

  • Hello.

    This is in fact the correct fix for this problem.

    It was accidentally introduced in 1.1.0. It was a side effect of having to initialize to 0 all static and global scope variables that were not explicitly initialized. CCE does not ensure that .bss objects are set to 0 so it has to be done explicitly. This has side effects and the scenario you found was missed.

    Hope this helps.

    lfriedman