11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Writing efficient codeWDTCNTCL = 0x0008,WDTTMSEL = 0x0010,WDTNMI = 0x0020,WDTNMIES = 0x0040,WDTHOLD = 0x0080};#define WDTPW(0x5A00)By including the appropriate include file in your source code, you make it possible toaccess either the object or any individual bit (or bitfields) from C code as follows:/* Object access */WDTCTL = 0x1234;/* Bitfield accesses */WDTCTL_bit.WDTSSEL = 1;If more than one bit must be written to a memory-mapped peripheral unit at the sametime, for instance to stop the watchdog timer, the defined bit constants can be usedinstead, for example:WDTCTL = WDTPW + WDTHOLD; /* Stop watchdog timer */You can also use the header files as templates when you create new header files for other<strong>MSP430</strong> devices. For details about the @ operator, see Located data, page 40.NON-INITIALIZED VARIABLESNormally, the runtime environment will initialize all global and static variables when theapplication is started.The compiler supports the declaration of variables that will not be initialized, using the__no_init type modifier. They can be specified either as a keyword or using the#pragma object_attribute directive. The compiler places such variables inseparate segment, according to the specified memory keyword. See the chapter Placingcode and data for more information.For __no_init, the const keyword implies that an object is read-only, rather than thatthe object is stored in read-only memory. It is not possible to give a __no_init objectan initial value.Variables declared using the __no_init keyword could, for example, be large inputbuffers or mapped to special RAM that keeps its content even when the application isturned off.For information about the __no_init keyword, see page 196. Note that to use thiskeyword, language extensions must be enabled; see -e, page 150. For information aboutthe #pragma object_attribute, see page 208.128<strong>MSP430</strong> <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>Reference Guide

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!