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.

CCS/CC2640R2F: Holding the AGC Constant in CCS

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640,

Tool/software: Code Composer Studio

Hello,

I'm currently trying to take IQ data measurements using the Constant Tone Extension methods discussed in the RTLS Toolbox material (SimpleLink CC2640R2 SDK). The examples used talk about taking just phase measurements for the AoA and ToF methods, but I'm interested in trying to take relative amplitude measurements across multiple packets, so I need the AGC to be held constant for that. I looked into a related issue (found here: https://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/t/751455?CC2640R2F-How-to-read-AGC-value), but the instructions/suggestions provided applied to SmartRF Studio; not Code Composer Studio. How might I go about forcing the AGC gain constant in the hardware registers through CCS? Better yet, if there is a way to just record the AGC gain settings without overriding the limits of the AGC, how would I go about accessing it? If possible, I would like to avoid using SmartRF Studio for setting overrides as I want to create a program for the CC2640 device in CCS.

Best Regards,

Matt

  • I have asked an expert to comment.

  • Hi Matt, 

    I see the use of both SmartRF Studio and Code Composer Studio (CCS) can seem confusing. SmartRF Studio can both be used as a "quick start"/verification of your LaunchPad, but also to configure your device with the most updated radio settings (or custom settings you would like).

    By using the "code export" button in SmartRF Studio, you will get some command structures defined in a .c/.h-file pair. The CMD_RADIO_SETUP will be part of these configurations, and will depend on a pointer to a overrides list. 

    The configuration you are looking for is achieved by putting the override as defined in the post you linked (https://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/t/751455?CC2640R2F-How-to-read-AGC-value

    Best regards,

    Vetle

  • Hi Vetle,

    I apologize for not getting back promptly. I followed your instructions for generating the .c/.h files needed to configure the radio parameters and a placed them in all of the project workspaces. When I first attempted to compile the projects for the slave, master, and passive CC2640 devices, I received an error reporting that the "RF_cmdFs" struct was already defined somewhere else in the program. Hoping that it would not conflict with the other command structures defined in the Smart RF settings files, I commented out all instances of "RF_cmdFs" in the .c/.h files. Once I confirmed that everything compiled without any errors, I flashed all the devices and I then tried to start up the Python script called "rtls_example_with_rtls_util.py." The program hangs and doesn't get past this point:

    On closer inspection, it appears that the master device eventually stops responding altogether (before making this modification, it did work and the program proceeded normally):

    Is there something that I might be doing wrong here? I'll gladly provide files if needed. Thank you for your time!

  • Hi,

    For the RTLS projects, it's currently not possible to read out AGC gain setting in the application layer.

    What you can do is to lock the AGC setting into low gain by adding 0x35886098 into the override list for rtls projects.

    The override list for rtls_master and rtls_slave is in ble_user_config.c under pOverrideCte[].

    You just need to add 0x35886098 before END_OVERRIDE

    For rtls_passive, the override list is in urfc.c.

    You need to add 0x35886098 into pOverrides1Mbps.

  • Hi Christin,

    I'm not sure if it's due to a version difference or not, but I couldn't find the "pOverrideCte[]" list under the "ble_user_config.c" file for the master and slave projects. The same applies for the passive device; I couldn't find the "pOverrides1Mbps" list, but I did find an override list called "ubRfRegOverride[]" and I appended your recommended override to the list and it appears to have worked. Since I was most concerned about holding the gain steady on the measuring device (the passive device), I left the master and the slave devices' overrides alone since I have control of the default transmit power. So far, it appears to work fine, so I think you solved my problem!

    If you don't mind me asking, in addition to setting the receiver gain to a lower, fixed value, are there any other fixed-gain overrides I could use (such as a setting for holding the gain at a maximum value)? I was hoping to add some flexibility to my modified project files, so I was looking to have a couple fixed gain settings in case they were needed.

    Also, this is somewhat outside the scope of the initial question since it's unrelated to the AGC settings, how can I go about limiting the channels used in the RTLS projects? I'm trying to limit the number of different carrier frequencies to reduce the variation in the magnitude data. I understand the frequency hopping is intended to have better immunity to multipath effects, but there is a lot of variation in the magnitude across the full range of channels. There were other posts suggesting that the "HCI_LE_SetHostChanClassificationCmd()" is supposed to be used after establishing a connection (reference here: https://e2e.ti.com/support/wireless-connectivity/bluetooth/f/538/t/507332, but it's unclear how to approach this in the context of the RTLS projects. If this needs to be brought up as a second and separate post, just let me know! Thanks for your assistance!

    All the best,

    Matt

  • P.S. Just ran a test measurement with a large chunk of RF-absorptive foam between the passive device and the slave device and found that the magnitude of the IQ data suddenly shoots up when the magnitude of the data should remain low. Is the transmit power automatically selected or could this be an issue of the AGC still being enabled?

    Just as a side note, I left an override that is related to the AGC in the "urfc.c" file:

    Could that override potentially mess with the amplifier override you specified?

  • Sorry, I have given you the wrong setting. Somehow I was under the impression that this is for CC26x2.

    Since you are using CC2640r2, you should change HW_REG_OVERRIDE(0x6084, 0x05F8) to HW_REG_OVERRIDE(0x6084, 0x0588) . This changes the AGC to low gain. And that's the only place you should set.

    To answer your 2nd question. As the comment said, you should call the HCI_LE_SetHostChanClassificationCmd in rtls_master project when the link has established.

    Then you will have to add a hook to restart passive with the updated channel map and hop values for passive to be able to continue tracking the connection and does I/Q sampling

  • Hi again Christin,

    With that correction to the AGC override, I can see that the magnitude does not vary even if the signal level drops low or if it gets too high, so it looks like that fixes the problem. With that being said, I've got a few more questions, if you don't mind me asking:

    1. If I wished to change the fixed gain override to a higher gain, can I accomplish that by changing the least significant byte of the override parameter? i.e. Instead of writing HW_REG_OVERRIDE(0x6084, 0x0588) to set the AGC to a fixed, low-gain state, writing HW_REG_OVERRIDE(0x6084, 0x05yy), where "yy" is the forced gain setting
    2. Under "rtls_master.c" file in the RTLSMaster_ProcessRoleEvent(...) function, I added a channel map array and called the HC_LE_SetHostChanClassificationCmd(...) function with the array as the function parameter in the GAP_LINK_ESTABLISHED_EVENT case. Is this the appropriate place to do this? Here's a snippet of how I write out that modification (channel's 16, 17, and 18 are enabled):
    3. Lastly, I have no idea where the "restart passive" hook belongs even after doing some serious digging into the literature for TI-RTOS (as I assumed that was the right place to start). I presumed it belongs in the "rtls_passive" project in code composer, but it is unclear where my modification is supposed to go. To perform a reset (connection reset, I believe), what do I have to do in the CCS workspace to make a reset happen after the channel map is configured on the master device?

    Thank you so much for your assistance!

    All the best,

    Matt

  • In the "rtls_agent" Python application (namely the examples), I discovered that the master device never reports that it successfully pairs when it reaches the "rtlsUtil.ble_connect(slave_bd_addr, connect_interval_mSec)" call. In the console window, I see the following:

    The timeout error was traced back to the "rtls_util.py" file immediately after the "self._master_node.rtls.connect(slave['addrType'], slave['addr'], interval)" line.

    Moving back to CCS: as I mentioned in my recent reply, I made a modification under the "GAP_LINK_ESTABLISHED_EVENT" event section to set the channel map before the master device sends its connection information to the passive device, but it appears that once that happens the master device cannot successfully connect with the slave. In addition to the questions above, I was hoping to ask if there is something else that I am supposed to do to get the slave device and the master to pair using the channel map I want to use? Thank you!

  • Hi,

    To answer your question:

    1. Yes, you can set the yy to 88, 99, AA, BB, CC, DD, EE, FF. 

    2. You can triggered the channel map update by adding a software clock after done with pairing/bonding to avoid what you see.

    3. This you will have to implement a new command yourself. Either that when master get a successful channel map update, you send a channel map updated command to the python. In python, you will have to implement a logic like if master sends a channel map update comment then passive needs a reset(RTLS_CMD_RESET_DEVICE). The reset command can be found in the ss_rtls.py.

    You should dig into rtls_control files to understand how it works instead of TI-RTOS.

  • Hi Christin,

    Is there easy way to go about adding a software clock immediately after pairing/bonding? Or is there a reference I could follow that will achieve a similar thing? I'm new to the topic of certain features like hooks and software clocks, but I'm only trying to implement them in the context of the RTLS toolbox in CCS. Thank you for your time!

  • You can take a look at simple_peripheral where when a link is established(GAP_LINK_ESTABLISHED_EVENT), it starts a software clock.

    You can copy how the clock is constructed and move the start clock under pairing/bonding callback.

    Since you are new to our software, I would also recommend you to take a look at our SimpleLink Academy Labs to get familiar with our software solution regarding TI-RTOS, BLE STACK...etc

    http://dev.ti.com/tirex/explore/node?a=pTTHBmu__3.30.00.03&node=AHjJ8SNDuLXt3h6qHE4-OA__pTTHBmu__3.30.00.03&r=krol.2c__3.10.00.15&r=krol.2c__2.40.00.32&r=pTTHBmu__3.20.00.68 

  • Hi Christin,

    Using your suggestion, I adapted the methods for creating the software clock from the "simple_peripheral" example and I did some reading on the "Timing Services" portion of the RTOS literature as well as some of the BLE STACK material to understand the example. Based on the example, the way the software clock is used is to post events to keep the application awake, and for the "simple_peripheral" example, it does so every 5 seconds for the "internal periodic events" after the link is established. My revised clock handler function looks like this:

    I had it originally set up to first start at the end of the GAP_LINK_ESTABLISHED_EVENT event if the status was successful, but the Python script stops abruptly a second after the measurement process begins. I've also tried placing the "clock start function" at the end of the "RTLSMaster_pairStateCb" since I presumed that's the callback you suggested I need to initiate the clock after:

    The above modifications *sometimes* works, but when it does work, the channel map modification doesn't appear to stick, and when it doesn't work, the Python script hangs (the program doesn't reach the "Try to stop AOA result parsing threadSTOP Command Received" dialog and never reports an error).

    After conducting more of an investigation, I came across some BLE-related material for a Nordic Semiconductor product (link: https://devzone.nordicsemi.com/f/nordic-q-a/25281/changing-the-default-channel-map-with-sd_ble_opt_set). In the post, one individual notes that per the BLE specifications the master/central device can update the channel map by sending out a "LL_CHANNEL_MAP_REQ PDU." If this information is relevant to my issue, Is there a way to determine if that PDU is ever being sent out? Or do you think that there is an issue with how I'm approaching the software clock/channel map update?

    All the best,

    Matt

  • Hi,

    I just realized that there is a bug regarding channel map update in current SDK.

    We have fixed the bug and the fix will come with our CC13x2_26x2 Q4 SDK. 

    You can subscribe to the SDK. Then you will get a notification when there is a new one available.

    http://www.ti.com/tool/SIMPLELINK-CC13X2-26X2-SDK

  • Hi,

    It's been roughly 2 weeks since I was last trying to tackle some issues surrounding the channel map configurations in the 3.30 SDK, and I found out a week ago that the 3.40 SDK was made available on the 23rd of December. I transferred all of my modifications over from the v3.30 RTLS examples to the v3.40 examples, and after accounting for the new changes, all the modifications except the channel map configuration compiled and worked correctly.

    Just to recap the changes I made to the program, I first set up a one-shot software clock in the "rtls_master.c" program in the initialization function. I defined the software clock handler and set it up to run the HCI_LE_SetHostChanClassificationCmd( ... ) when the handler is called. The software clock is started at the end of the RTLSMaster_pairStateCb( ... ) function is called in the pairing process. The idea behind my modifications is that the channel map can only be changed after bonding over BLE, so the channel map is changed after the pair state callback function is ran since the function is called immediately after bonding.

    Christin Lee had informed me that this was a known problem with the v3.30 SDK and that I should expect this to be resolved with the next SDK (presumably the v3.40 SDK). Either the channel map configuration function doesn't work still or I'm not using it correctly. Is it possible that I'm just doing something wrong here? I'll gladly provide more information if needed. Thank you for your time!

    Edit: Just for reference, despite the original post being for the CC2640R2F device, I am using the CC26x2 device and the SDK's corresponding to that device

    Edit 2: One additional question, if you don't mind me asking, is there any reference code I could take a look at to see how the HCI_LE_SetHostChanClassificationCmd( ... ) function works or are there any examples that you might reference to show how the function is used properly?