5 Replies Latest reply on Feb 21, 2020 1:11 AM by GaneshD_41

    How to change public address within program

    DeCo_1926091

      i've managed to confuse myself again.  I'd really appreciate it if someone could unconfuse me.

      1.  i have a PSoC4 BLE based remote server talking to an iPad. 
      2.  The remote's Public Address is set in the BLE component (not silicon generated) and programmed into the PSoC.

      3.  At some time during the remote's operation (when a PB switch is pressed) I want to change the Public Address.
      4.  This new Public Address should stay active, even through power cycling, until the chip is again reprogrammed or the PB switch is pressed again.

      Without boring you with all the things I've tried, if you could tell me how to do this it would make my day a whole lot better.
      Thanks,

      Dennis

        • 1. Re: How to change public address within program
          GaneshD_41

          Hi,

           

          The Public address of the device is stored in Row 0 of the user SFLASH data. So if you want to change the public address in run time, you have to write the address in to Row 0 of the user SFLASH whenever you want to write(on pin interrupt event).

           

          Please note that to write into user SFLASH you have to write in to entire row (256 bytes in case of CY8C4248LQI-BL583) device.

           

          For example, If you want to write the address CC DD AA 33 22 11 as public address you have to do the following steps:

           

          1. Declare uint8 rowdata[256]={0};

          2. Assign the address you want

                  rowdata[0]=0x11;

                  rowdata[1]=0x22;

                  rowdata[2]=0x33;

                  rowdata[3]=0xAA;

                  rowdata[4]=0xDD;

                  rowdata[5]=0xCC;

                  rowdata[6]=0x00 (for public address)

           

          3. Call the API

          CySysSFlashWriteUserRow(0, rowdata);

          The above API is found in PSoC4 System reference guide.

           

          Please note that the address will be applicable only after the next boot cycle.

           

          You can also look at the following KBA for more information.

           

          Setting Bluetooth Device Address – KBA211407

           

          Thanks

          Ganesh

          • 2. Re: How to change public address within program
            DeCo_1926091

            Hi Ganesh,

             

            Thanks for your reply.  I started by trying to read that location in SFLASH, expecting to find the same device address as I put into it in the BLE component configurator.  Instead I found all zeros.  Did I do something wrong or is the original stored somewhere else and something tells the code to get it from the SFLASH if the SFLASH location is non-zero?

             

            Dennis

            • 3. Re: How to change public address within program
              GaneshD_41

              Hi Dennis,

               

              How are you actually reading SFlash data? Please try reading them through Debug window.

               

              Please find the attached project and attached image showing that the public address set in the program is appearing in the 0x0FFFF400 location of the device.

               

              Thanks and regards

              Ganesh

              • 4. Re: How to change public address within program
                DeCo_1926091

                Hi Ganesh,

                 

                *** Added edit:   I forgot to tell you I was reading the location in the debug window. 

                 

                i still was unable to find the board address at the location you sent.  However, I did find the following in the file BLE_1.h, at line 560:

                 

                /* Device address stored by user in ROW4 of the SFLASH */

                 

                Maybe that's a left over comment from earlier code or maybe the documentation you and I have been looking at has not picked up a change in the code.

                 

                What do you think?

                 

                Tthanks,

                Dennis

                • 5. Re: How to change public address within program
                  GaneshD_41

                  Hi Dennis,

                   

                  >>"I still was unable to find the board address at the location you sent."

                  --> Can you please attach a demo project that reproduces your issue so that we can test it at our side?

                   

                  >>"What do you think?"

                  --> The ROW4 they are mentioning in the BLE.h file and the ROW0 I have mentioned in my response points the same. I mean if you see the value of the MACRO CYREG_SFLASH_MACRO_0_FREE_SFLASH0 it is 0x0FFFF400. I will check with internal team regarding the ROW0 and ROW4 confusion.

                   

                   

                   

                  Thanks and regards

                  Ganesh