How to use calibration in RAIL

by <a href=""><font color="#000000"><font size="2">Hero Employee</font></font> </a> andrasbiro ‎10-19-2016 11:28 AM - edited ‎12-16-2016 03:54 AM

RAIL provides two self calibrations: Temperature (TEMP or TEMP_VCO) and Image rejection (ONETIME or ONETIME_IRCAL)


Temperature calibration


The calibration needs to be taken place when the temperature crosses 0 degC, or when it increases by more than ~70 degC relative to the temperature of the last calibration, while sitting in receive state. It automatically runs every time it enters receive, so if you are frequently forcing a re-enter into receive mode you may not need to enable calibration.


Basically, you don't need this calibration, unless you use the chip in RX mode for a long time.


Image rejection calibration


What does one-time mean?


It means once per chip, and once per PHY config. You can do it during the manufacturing process, and you don't need to do it ever again (if you store it in non-volatile memory). If your product uses multiple configurations, you just store multiple calibration consts.


Does this work on every possible PHY?


Unfortunately not, it only works on sub-GHz configs. On 2.4GHz RAIL_CalStart will load a factory calibrated value from the device information (DI) page of the chip, which is an OK value for 2.4G, but the actual calibration on the sub-GHz band is much better. Two values are stored, one for OQPSK modulation, and one for everything else. So, you don't have to do the "calibration" if you change between two FSK based 2.4GHz configuration.


When and how does this calibration happen?


If you call RAIL_ChannelConfig, RAIL will call the RAILCb_CalNeeded callback. If you didn't implement this callback, it will ask for a calibration with RAIL_CalStart, but it will not store the results.


Should I store the calibration const?


You should, in two cases:
-Chip initialization time is important: Otherwise, RAIL will calibrate itself on each bootup
-You use multiple PHYs: Each time you change the PHY, you trigger a calibration, which extends the time of the PHY change (the exception is 2.4GHz, where you would only load the factory stored value again)


Should I do anything during initialization?


Yes: Every PHY configuration comes with an irCalConfig array. It should be uploaded with RAIL_CalInit. If you have multiple PHY-s you should upload the irCalConfig array each time you change the PHY, if you want to actually calibrate, not just loading stored values.


How should I call RAIL_CalStart to store and to reuse the calibration const?


If you call RAIL_CalStart, it works differently, depending on the first argument

  • If it's a NULL pointer, it will do the one time calibration, but won't save it
  • If it's a pointer with the value of RAIL_CAL_INVALID_VALUE, it will do the calibration, than overwrite the pointer with the calibration value
  • If it's anything else, it will just write the calibration value to the appropriate registers


So, you should do something like this to store the const:

RAIL_CalValues_t calValues = RAIL_CAL_INVALID_VALUE;
RAIL_CalStart(&calValues, RAIL_CAL_ALL_PENDING, true);
<store calibration values>



To restore it:

RAIL_CalValues_t calValues = <get calibration values>;
RAIL_CalStart(&calValues, RAIL_CAL_ALL_PENDING, false);



And you probably want to do this from the RAILCb_CalNeeded callback.