[AVR单片机] 简单的C语言语句

[复制链接]
4456|9
 楼主| hufa123 发表于 2010-11-30 15:34 | 显示全部楼层 |阅读模式
ATMGE128手册中 关于EEPROM的读写操作中有段代码
void EEPRON_write(unsigned int uiaddress,unsigned int ucdata)
{
   /*等待上次写结束*/
   while(EECR&(1<<EEWE));
    /*设置地址和数据寄存器*/
   EEAR=uiaddress;
   EEDR=ucdata;
  /*置位EEMWE*/
EECR|=(1<<EEMWE);
  /*置位EEWE启动写操作*/
EECR|=(1<<EEWE);
}  
   中的1<<EEMWE 是怎么运算 能刚好把EECR中的 EEMWE 位置1?
472666GAQ 发表于 2010-11-30 15:42 | 显示全部楼层
EEWE 其实这个东西是代表一个数字的 你去GCC的文件看一下你就明白了~~
 楼主| hufa123 发表于 2010-11-30 16:19 | 显示全部楼层
GCC文件? 没找到。。
472666GAQ 发表于 2010-11-30 18:40 | 显示全部楼层
用AVR Studio 4  不要直接用GCC   然后就能看见了

/* Copyright (c) 2004 Eric B. Weddington
   All rights reserved.

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

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

   * 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.

   * Neither the name of the copyright holders nor the names of
     contributors may be used to endorse or promote products derived
     from this software without specific prior written permission.

  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 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. */

/* $Id: iom16.h,v 1.14.2.6 2009/02/11 18:05:26 arcanum Exp $ */

/* avr/iom16.h - definitions for ATmega16 */

#ifndef _AVR_IOM16_H_
#define _AVR_IOM16_H_ 1

/* This file should only be included from <avr/io.h>, never directly. */

#ifndef _AVR_IO_H_
#  error "Include <avr/io.h> instead of this file."
#endif

#ifndef _AVR_IOXXX_H_
#  define _AVR_IOXXX_H_ "iom16.h"
#else
#  error "Attempt to include more than one <avr/ioXXX.h> file."
#endif

/* Registers and associated bit numbers */

#define TWBR    _SFR_IO8(0x00)

#define TWSR    _SFR_IO8(0x01)
#define TWPS0   0
#define TWPS1   1
#define TWS3    3
#define TWS4    4
#define TWS5    5
#define TWS6    6
#define TWS7    7

#define TWAR    _SFR_IO8(0x02)
#define TWGCE   0   
这是文件中的一部分
 楼主| hufa123 发表于 2010-11-30 21:38 | 显示全部楼层
原来是EEWE是一单纯的数字 不像PIC中每个位的代号啊:)
928315 发表于 2010-12-4 10:26 | 显示全部楼层
宏定义的数字啊。
windlrh 发表于 2010-12-5 18:07 | 显示全部楼层
谢谢,学习了。
windlrh 发表于 2010-12-5 18:07 | 显示全部楼层
帮楼主堆高房子
мe.蒾鋩 发表于 2010-12-7 10:26 | 显示全部楼层
老鱼探戈 发表于 2010-12-11 13:10 | 显示全部楼层
貌似已经解决了  :victory:
您需要登录后才可以回帖 登录 | 注册

本版积分规则

186

主题

393

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部