IQRF+CC5X Code Optimization

swToday we start with the 1st part of the series of articles dedicated to writing an optimized code for IQRF platform using CC5X C compiler. This can be useful when there is not enough FLASH or RAM available or if there is a need to have the fastest code as possible.

Every part describes one optimization technique. We will not publish well known techniques taught at C language programing courses but methods that work well at our environment. Some tricks will save RAM, some FLASH, some both. Usually there is also some execution speed effect too. Optimization techniques can be even combined. Some of them might not be worth implementing because of the high maintenance and effort they require. It is advised to inspect .lst output file in order to check the generated code. Please note that code examples are illustrative only.

Let’s start!

 Part 1 – W as a Temporary Variable

When there is no risk of W register value change because of generated code, W can be used as a temporary variable.

Original code

if ( byte & mask )
  bufferCOM[ 0 ]  = 0xAB;
else
  bufferCOM[ 0 ]  = 0xCD;

Optimized code

if ( byte & mask )
  W = 0xAB;
else
  W = 0xCD;

bufferCOM[ 0 ] = W;

Effects

 ikony_flash ikony_ram  ikony_speed
SAVED NO EFFECT
NO EFFECT

Post sent by Hynek Syrovátka.

Leave a Reply

Your email address will not be published. Required fields are marked *