This is the way it's already done in usbdhid.c and usbdcdc.c so I just copied that code. Without it, you either get an exception (if the "bitbanding" address is outside of the memory space mapped in the MMU) or a memory overwrite (depending on your DDR size, due to memory aliasing).
//*****************************************************************************
+//This macro is used to diable the bit band operartion. Need to undefine this macro to use the
+// bit band operation.
+//***************************************************************************
+#define DISABLE_BIT_BAND
+
+//*****************************************************************************
//
[...]
SetDeferredOpFlag(volatile unsigned short *pusDeferredOp, unsigned short usBit,
tBoolean bSet)
{
+#ifdef DISABLE_BIT_BAND
+ if(bSet)
+ {
+ HWREG(pusDeferredOp) |= (1<<usBit);
+ }
+ else
+ {
+ HWREG(pusDeferredOp) &= ~(1<<usBit);
+ }
+#else
//
// Set the flag bit to 1 or 0 using a bitband access.
//
HWREGBITH(pusDeferredOp, usBit) = bSet ? 1 : 0;
+#endif
}
Thanks,
Orjan