View Full Version : Bit-banding in the XMC4500

Nov 23rd, 2012, 03:04 PM
ARM's Cortex-M4 Devices Generic User Guide (sec 2.2.5) specifies an optional bit-banding feature.

It is not mentioned in the Infineon XMC4500 reference manual. Does the XMC4500 support bit banding?

Nov 28th, 2012, 08:45 AM
The XMC4000 family does not support bit-banding.

Most peripherals in the devices provide different means of direct bit manipulation, e.g. *SET and *CLR registers, allowing to modify individual or groups of bits and bit fields.
Another example is the Output Modification Register (OMR) of the Ports, which allows to set, clear or toggle single or multiple GPIO pins of the respective Port with a single access.

Nov 29th, 2012, 04:21 PM
Andreas, Thanks for your reply.

Yes, I see that writing to a pin using DAVE app IO004 eventually results to a write to the port's OMR register.

However this is so slow and inefficient! To improve speed, the DAVE app could be rewritten to use #defines for bit positions rather than shifts for every call. Of course this would take more code space.

My XMC4500 running at 120MHz takes
621ns to set a pin high using IO004_SetOutputValue
530ns to set a pin low using IO004_SetOutputValue

Yes the OMR allows you to change port pins atomically which is great, but you still have to spend time assembling a 32bit image of the bits you want to affect, before writing the result to the OMR. It's cumbersome.

So I wanted to see just how fast I could toggle a pin. The advantage of the toggle feature of the OMR allowed me to get 33MHz by writing two instructions in assembly: transferring a register to the OMR and branch back.
However, toggling using the DAVE app is... slowww. Bit-banding would have helped a lot.

I would have loved to have both your present implementation -and- bit-banding both on your silicon.

Also I think bit-banding would have also improved the efficiency of C bit field constructs. Oh well.

Dec 3rd, 2012, 02:59 AM
You are welcome, Murray.
I am not really an expert on bit-banding, but I try to comment anyway...

I am sure bit-banding has its merrits, but also some limitations and drawbacks.
Bit-banding accesses are executed as read-modify-write operations, meaning that the CPU reads the full (e.g.32bit) register, manipulates the addressed bit and writes the full register back. So if you just want to set or clear a single bit, you still have two bus accesses.
Also, assembling a write mask for multiple bits that shall be updated in the same register may still be more efficient in system performance than a bunch of bit-banding accesses.
The read-modify-write operation may also have a drawback regarding registers with mixed content regarding status and control bits. If you have a status flag that may be set by hardware and cleared by software in the same register, a read-modify-write operation to a different bit in the same register may result in missing/losing information. Similar for bits that are cleared when read.

I also don't think that bit-banding really supports bit fields, but is limited to accesses to individual bits. Taking the OMR example, if you want to toggle two pins as a differential pair, bit-banding would always have some delay between the switching of the two pins, while that's easily possible without delay with a single write operation to the OMR register.
Similarly, bit-banding will not help in accessing "true" bit fields, like the IOCRx.PCy bit field (to stick with the Port example)...