怎样从PSoC 3/5 的 EEPROM 中读取数据?下面就从EEPROM说起。EEPROM处于PSoC3/5内存空间里,EEPROM的最大值容量是2 KB。通过SPC可以写EEPROM,而读EEPROM可以通过PHUB。此外,CPU或DMA都可以直接访问EEPROM数据。EEPROM的存储器的基本指针定义在ydevice.h 的CYDEV_EE_BASE。 该定义通过PHUB可以用来存取EEPROM数据。
Example to read first 255 bytes from EEPROM and store to array.
1.Reading EEPROM using CY_GET_REG8 API
for (count = 0; count < 255;i++)
EEPROM_Data[count] = CY_GET_REG8(CYDEV_EE_BASE + count);
2.Reading EEPROM using data Pointer
A pointer can be defined for the EEPROM address as follows:
#define EEPROM_ADDR (unsigned char *) CYDEV_EE_BASE
for (count = 0; count < 255; i++)
EEPROM_Data[count] = EEPROM_ADDR[count];
3.Reading using DMA
The same base address can be used while reading using DMA.
MyCh = DMA_DmaInitialize(0,0,0,0);
MyTd = CyDmaTdAllocate();
CyDmaTdGetConfiguration(MyTd, 255, DMA_INVALID_TD, (TD_INC_SRC_ADR | TD_INC_DST_ADR));
CyDmaTdSetAddress(MyTd, (uint16) CYDEV_EE_BASE, (uint16) EEPROM_Data) |