SW006012 Microchip Technology, SW006012 Datasheet - Page 113

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
© 2007 Microchip Technology Inc.
2. Unsafe:
3. Safe:
The first is safe because any interrupt falls outside the boundaries of the expression.
The second is unsafe because the application demands that bar and baz be updated
synchronously with each other. The third is probably safe; foo will possibly have an old
value, but the value will be consistent with the data that was available at the start of the
expression.
EXAMPLE 7-2:
Another variation depends upon the type of foo, bar and baz. The operations, "read
bar", "read baz", or "write back result to foo", may not be atomic, depending upon the
architecture of the target processor. For example, dsPIC DSC devices can read or write
an 8-bit, 16-bit, or 32-bit quantity in 1 (atomic) instruction. But, a 32-bit quantity may
require two instructions depending upon instruction selection (which in turn will depend
upon optimization and memory model settings). Assume that the types are long and
the compiler is unable to choose atomic operations for accessing the data. Then the
access becomes:
Now there are more possibilities for an update of bar or baz to cause unexpected data.
EXAMPLE 7-3:
A third cause for concern are bit fields. C allows memory to be allocated at the bit level,
but does not define any bit operations. In the purest sense, any operation on a bit will
be treated as an operation on the underlying type of the bit field and will usually require
some operations to extract the field from bar and baz or to insert the field into foo.
The important consideration to note is that (again depending upon instruction architec-
ture, optimization levels and memory settings) an interrupted routine that writes to any
portion of the bit field where foo resides may be corruptible. This is particularly appar-
ent in the case where one of the operands is also the destination.
The dsPIC DSC instruction set can operate on 1 bit atomically. The compiler may select
these instructions depending upon optimization level, memory settings and resource
availability.
read bar
interrupt modifies baz
read baz
perform operation
write back result to foo
read bar
read baz
interrupt modifies bar or baz
perform operation
write back result to foo
read lsw bar
read msw bar
read lsw baz
read msw baz
perform operation (on lsw and on msw)
perform operation
write back lsw result to foo
write back msw result to foo
TYPE OF FOO, BAR AND BAZ
BIT FIELDS
Interrupts
DS51284F-page 107

Related parts for SW006012