<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF21540 SPI Gain Dynamic Control</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98922/nrf21540-spi-gain-dynamic-control</link><description>Hi there, 
 Does the nRF Connect SDK support configuring the nRF21540 gain using SPI for values other than +10 and +20? 
 
 Looking at this previous Devzone question ( ) it is mentioned that only GPIO-based gain setting is supported, which I believe restricts</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Apr 2023 20:04:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98922/nrf21540-spi-gain-dynamic-control" /><item><title>RE: nRF21540 SPI Gain Dynamic Control</title><link>https://devzone.nordicsemi.com/thread/422372?ContentTypeID=1</link><pubDate>Tue, 25 Apr 2023 20:04:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a9c4a2e-836c-438a-824b-bb125e9f5a58</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Sean,&lt;/p&gt;
&lt;p&gt;MPSL controls the FEM using power models (see more about power model &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/nrf/app_dev/working_with_fem/index.html#using-fem-power-models"&gt;here&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;default power model is setup so that the FEM gain is&amp;nbsp;as close to&amp;nbsp;+10 dB and +20 dB as possible. The FEM gain can be influenced by variations of voltage, temperature, and signal frequency; and MPSL uses the TX_GAIN register to tweak the gain to compensate for such influences.&lt;/p&gt;
&lt;p&gt;mpsl_fem_pa_is_configured()&amp;nbsp;only gives you +10 and +20 dB depends on what the &amp;quot;target&amp;quot; TX gain is. The &amp;quot;configured&amp;quot; gain in the nRF21540 can be the same value, but could also be different.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To find out the actual configured TX gain value, you will need to read the TX_GAIN register. I am not sure how complicated&amp;nbsp;it would be to setup, as MPSL otherwise has control over the SPI interface.&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;you wish for&amp;nbsp;a different FEM control strategy, it is also possible to implement your own power model. Please note that the&amp;nbsp;gain is not calibrated, so when you set the FEM to a particular TX gain,&amp;nbsp;the FEM&amp;nbsp;will only actually achieve an approximate of the desired value.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I hope this explanation satisfies you. My apology for the incorrect information in my first reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF21540 SPI Gain Dynamic Control</title><link>https://devzone.nordicsemi.com/thread/421898?ContentTypeID=1</link><pubDate>Sun, 23 Apr 2023 15:57:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7f32ea7-6672-4b71-952d-2cc7566fe274</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Sean,&lt;/p&gt;
&lt;p&gt;You are right. I can&amp;#39;t believe how I missed the TX_GAIN bits in CONFREG0. Let me check with MPSL/FEM engineers and get back to you soon.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF21540 SPI Gain Dynamic Control</title><link>https://devzone.nordicsemi.com/thread/421891?ContentTypeID=1</link><pubDate>Sun, 23 Apr 2023 07:09:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c174fb4-fd18-4623-87a7-ffa0d99757fe</guid><dc:creator>FARLY7</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t think your reply is correct, the nRF21540 gain &lt;em&gt;can&lt;/em&gt; be set to values other than +10 and +20.&lt;/p&gt;
&lt;p&gt;The nRF21540 has a Tx Gain register that is writable over SPI to set the gain at more granular values, separate from the values found in UICR. Several other DevZone questions confirm this is possible. The Nordic radio_test sample also allows you to configure the FEM Gain register.&lt;/p&gt;
&lt;p&gt;When I set the power through the API described above, these are the selected tx powers that I receive.&lt;/p&gt;
&lt;p&gt;As you can see, it does not look like the nRF Connect SDK is correctly using the 1dB resolution of the Tx Gain register but&amp;nbsp;is defaulting to using the MODE pin/register.&lt;/p&gt;
&lt;table height="82" width="249"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Request Tx power&lt;/td&gt;
&lt;td&gt;Selected Tx Power&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-40&lt;/td&gt;
&lt;td&gt;-30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-20&lt;/td&gt;
&lt;td&gt;-30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-16&lt;/td&gt;
&lt;td&gt;-30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-12&lt;/td&gt;
&lt;td&gt;-30&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-8&lt;/td&gt;
&lt;td&gt;-10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-4&lt;/td&gt;
&lt;td&gt;-6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;-2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;-2&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;18&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I should be able to achieve a Tx power closer to the requested Tx power if the&amp;nbsp;nRF Connect SDK FEM driver&amp;nbsp;is correctly using the Tx Gain register.&lt;/p&gt;
&lt;p&gt;Is there something in my configuration I am doing wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF21540 SPI Gain Dynamic Control</title><link>https://devzone.nordicsemi.com/thread/421605?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2023 23:36:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00538500-04d6-4bbf-bbff-f2b61000195a</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Update:&amp;nbsp;This reply&amp;nbsp;&lt;em&gt;&lt;span style="text-decoration:underline;"&gt;incorrectly&lt;/span&gt;&lt;/em&gt; says&amp;nbsp;that the nRF21540 Gain cannot be finely controlled via the SPI interface. &lt;br /&gt;That is not the case. The nRF21540 Gain &lt;em&gt;&lt;span style="text-decoration:underline;"&gt;can&lt;/span&gt;&lt;/em&gt; be finely controlled via the SPI interface. However, there are some caveats. Please read the full discussion.&lt;/p&gt;
&lt;p&gt;Hi Sean,&lt;/p&gt;
[quote user=""]Should I expect to see FEM gain values other than +10 and +20?[/quote]
&lt;p&gt;The nRF21540 &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf21540/chapters/device_control/doc/tx_power_control.html?cp=8_0_0_4_3"&gt;can only switch between the two output power levels POUTA and POUTB&lt;/a&gt;. The +10 dB and +20 dB gain you observed are the &lt;em&gt;production&lt;/em&gt; default value of these two levels.&lt;/p&gt;
&lt;p&gt;The value of POUTA and POUTB can be configured by writing to&amp;nbsp;the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf21540/chapters/confreg/doc/register_interface.html?cp=8_0_0_7_0_2#register.CONFREG2"&gt;CONFREG2&lt;/a&gt; and &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf21540/chapters/confreg/doc/register_interface.html?cp=8_0_0_7_0_3#register.CONFREG3"&gt;CONFREG3&lt;/a&gt; registers. However, &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf21540/chapters/device_control/doc/operating_state.html?cp=8_0_0_4_0"&gt;they are one time programmable&lt;/a&gt;, and as such is not fit to be use in runtime.&lt;/p&gt;
&lt;p&gt;It is for this reason that a more granular control of the&amp;nbsp;TX Power is not possible. Only combinations of POUTA or POUTB and the SoC&amp;#39;s TX power can be achieved.&lt;/p&gt;
&lt;p&gt;Please also note that the&amp;nbsp;nRF21540 also has a max output power of 22 dBm, even when the sum of SoC TX Power and FEM TX Gain is higher.&lt;/p&gt;
[quote user=""]Is my method of setting the Tx power &amp;quot;at the antenna&amp;quot; correct?[/quote]
&lt;p&gt;I will need to double check on the HCI command. However, given the fact that you see a change in FEM Gain, it might be correct. To be sure, can you also look at the TXPOWER register, to see if it changes with each call of your function?&lt;/p&gt;
&lt;p&gt;You mentioned that you refer it from DevZone. May I ask for the source?&lt;/p&gt;
[quote user=""]Is my method of querying the current gain of the FEM correct? It seems strange that it requires a delay beforehand. I followed this API down and it looks like it reads from a cached value in the stack rather than querying the FEM register directly, which doesn&amp;#39;t fill me with as much confidence that it is accurate.[/quote]
&lt;p&gt;According to &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.3.0/nrfxlib/mpsl/doc/api.html#c.mpsl_fem_pa_is_configured"&gt;the documentation&lt;/a&gt;, it is correct. Could you please give some more details about&amp;nbsp;the &amp;quot;reads from a cached value&amp;quot; part? From what cache is the gain fetched, and why would that make you doubtful?&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>