Subject: Put this in the EFI email folder RPM Bit Banding & math
From: AAA-rotaryeng
Date: 2/2/2013, 11:42 AM
To: AAA-rotaryeng
CC: mikroElektronika Support Center <support@mikroe.com>


 What the heck is Bit-Banding? I am no expert in this subject but I
 will do my best to explain it here as I understand it now. Bit-Banding
 is a feature of the ARM processor.

 This bit-banding operation greatly simplifies bit manipulations.
 Instead of reading a byte, AND?ing in the appropriate bit, and then
 writing the byte back out, as done in the old 8 bit embedded
 processors, bit-banding accomplishes this with a single store
 instruction.

 Example of Bit-Banding

 Bit-banding uses address space that aliases peripheral or static ram
 address space, allowing a single bit within a byte to be manipulated
 by a reference to a byte at an aliased address.

 In computing, aliasing describes a situation in which a data location
 in memory can be accessed through different symbolic names in the
 program. In other words the programmer assigns a name to a memory
 location. Lets say we want to turn a light on in the instrument panel
 when the oil pressure drops to a dangerous level. The programmer would
 call it the "oil-pressure-light". It only needs one on or off bit
 (wire) to do this just like the light switch in your house.

 For example, a write to address 0x20000000 modifies the static ram
 32-bit word at that location, but writing to 0x28000000 modifies only
 bit 0 at address 0x20000000.

 Static random-access memory (SRAM) is a type of semiconductor memory
 that uses bistable latching circuitry to store each bit. The term
 static differentiates it from cheaper dynamic RAM (DRAM) which must be
 periodically refreshed. Static RAM is widely used in embedded
 processors as unlike PC's it takes no valuable programming time to
 refresh. Time is of the essence when you are controlling machines.

 With the prior method of bit manipulations with sequential
 instructions doing the read-modify-write operations, a hardware
 interrupt could occur which, potentially, could change a bit at that
 memory location.
 After the interrupt returns, the store could be writing corrupt data
 back to that memory location.


 Paul Lamar



Paul,

Cortex M-3 and Cortex M-4 do support bit banding,  but look closely at
the compiled code as often you might find it did a byte manipulation.

Hint when you have a tech support question, put the question as simple
as possible, so you get a straight forward response:

Two Examples:
I have a problem at reset, my board acts strange.  vs.
What is that status of GPIO4-7 when RESET_N is asserted?

Not that it isn't a valid question, but when you get 30 of those a day,
what would you respond to immediately, vs put at the bottom of the queue?

Tom W


Thanks for the tip Tom. MikroPro IDE allows looking at the
ASM source.

Here is some info on the math.

Types Efficiency .

Computer Types for the new comer.

 In most cases, a programming language defines a set of basic data types, e.g. for numbers, characters or strings. In higher languages, it is often possible to define new data types from the existing ones, for example, to represent a postal address (consisting of strings for street and city and integers for the postal code).

First of all, the user should know that ARM's ALU, which performs arithmetic operations, is optimized for working with 32-bit types.

Also, it performs hardware multiplication and division on the integer (16 bit) level. This is much faster than doing it in ASM.

This really helps in time critical programs controlling hardward
such as EFI systems.

Here is a list of types supported in MikroPro BASIC.

Paul Lamar
-- 
The Rotary Engine News Letter. Powered by Linux.
ACRE NL web site. http://www.rotaryeng.net
You Tube http://tinyurl.com/beqqxas
Copyright 1998-2013 All world wide rights reserved.