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;
  bufferCOM[ 0 ]  = 0xCD;

Optimized code

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

bufferCOM[ 0 ] = W;


 ikony_flash ikony_ram  ikony_speed

Post sent by Hynek Syrovátka.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.