XMEGA Application Note


ccpwrite.h File Reference

Header file for CCP write helper function. More...

#include "avr_compiler.h"

Include dependency graph for ccpwrite.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void CCPWrite (volatile uint8_t *address, uint8_t value)
 CCP write helper function written in assembly.


Detailed Description

Header file for CCP write helper function.

This file only contains a function prototype.

Application note:
AVR1010: Minimizing the power consumption of XMEGA devices
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Revision
2770
Date
2009-09-11 10:55:22 +0200 (fr, 11 sep 2009)

Copyright (c) 2008, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file ccpwrite.h.


Function Documentation

void CCPWrite ( volatile uint8_t *  address,
uint8_t  value 
)

CCP write helper function written in assembly.

This function is written in assembly because of the time-critial operation of writing to the registers.

Parameters:
address Pointer to the register to write to.
value Value to write to the register.

Definition at line 65 of file ccpwrite.c.

References ENTER_CRITICAL_REGION, and LEAVE_CRITICAL_REGION.

Referenced by main().

00066 {
00067     ENTER_CRITICAL_REGION( );
00068 #ifdef __ICCAVR__
00069 
00070     asm("movw r30, r16");
00071 #ifdef RAMPZ
00072     RAMPZ = 0;
00073 #endif
00074     asm("ldi  r16,  0xD8 \n"
00075         "out  0x34, r16  \n"
00076 #if (__MEMORY_MODEL__ == 1)
00077         "st     Z,  r17  \n");
00078 #elif (__MEMORY_MODEL__ == 2)
00079         "st     Z,  r18  \n");
00080 #else /* (__MEMORY_MODEL__ == 3) || (__MEMORY_MODEL__ == 5) */
00081         "st     Z,  r19  \n");
00082 #endif /* __MEMORY_MODEL__ */
00083 
00084 #elif defined __GNUC__
00085     volatile uint8_t * tmpAddr = address;
00086 #ifdef RAMPZ
00087     RAMPZ = 0;
00088 #endif
00089     asm volatile(
00090         "movw r30,  %0"       "\n\t"
00091         "ldi  r16,  %2"       "\n\t"
00092         "out   %3, r16"       "\n\t"
00093         "st     Z,  %1"       "\n\t"
00094         :
00095         : "r" (tmpAddr), "r" (value), "M" (CCP_IOREG_gc), "i" (&CCP)
00096         : "r16", "r30", "r31"
00097         );
00098 
00099 #endif
00100     LEAVE_CRITICAL_REGION( );
00101 }

@DOC_TITLE@
Generated on Mon Nov 9 13:44:29 2009 for XMEGA power consumption evaluation code by doxygen 1.5.9