单片机学习小组
直播中

申根换

7年用户 1567经验值
私信 关注

N76E003读取flash(eeprom)例程中为什么要右移8位的?

//***********************************************************************************************************
//  File Function: N76E003 APROM program DATAFLASH as EEPROM way
//***********************************************************************************************************
#include "N76E003.h"
#include "Common.h"
#include "Delay.h"
#include "SFR_Macro.h"
#include "Function_define.h"

#define ADDR_BASE 0x4700

#define FLASH_L_LOW                        ADDR_BASE+1
#define FLASH_L_HIGH                ADDR_BASE+2
#define FLASH_H_LOW                        ADDR_BASE+3
#define FLASH_H_HIGH                ADDR_BASE+4

volatile unsigned char xdata page_buffer[128];


UINT8 Read_APROM_BYTE(UINT16 code *u16_addr)
{
    UINT8 rdata;
    rdata = *u16_addr>>8;
    return rdata;
}

*u16_addr>>8;为什么要右移的?



回帖(1)

kmno4

2024-1-11 15:52:10
The shift right by 8 bits (>>) is used to obtain the high byte of the data stored in the flash memory. In this specific code, it is used to read the data from the EEPROM (which is emulated using the flash memory of the N76E003 controller), since it is stored in a word (2-byte) format with the high byte stored first followed by the low byte. Therefore, shifting right by 8 bits will get the high byte of the data and shifting left by 8 bits will get the low byte of the data.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分