beautypg.com

An266, 1 “read flash id” sample code – Cirrus Logic AN266 User Manual

Page 3

background image

AN266

AN266REV1

3

3.1

“Read Flash ID” Sample Code

ULONG ulMakerCode;

ULONG ulDeviceCode;

ULONG ulIDData;

*GPIO_PBDDR = 0x5E;

//

// Write Read ID Command

//

*GPIO_PBDR = 0x14;

*GPIO_PCDR = 0x90;

*GPIO_PCDDR = 0xFF;

*GPIO_PBDR = 0x06;

//

// Write Reading ID Address

//

*GPIO_PBDR = 0x0C;

*GPIO_PCDR = 0x00;

*GPIO_PCDDR = 0xFF;

*GPIO_PBDR = 0x06;

//

// Prepare to Read Data from IO

//

*GPIO_PCDDR = 0x00;

//

// Read Maker Code

//

*GPIO_PBDR = 0x02;

ulMakerCode = *GPIO_PCDR;

*GPIO_PBDR = 0x06;

//

// Read Device Code

//

*GPIO_PBDR = 0x02;

ulDeviceCode = *GPIO_PCDR;

*GPIO_PBDR = 0x06;

//

// Don't care this byte

//

*GPIO_PBDR = 0x02;

ulIDData = *GPIO_PCDR;

*GPIO_PBDR = 0x06;

//

// Read Page Size, Block Size, Spare Size, Organization

//

*GPIO_PBDR = 0x02;

ulIDData = *GPIO_PCDR;

*GPIO_PBDR = 0x06;

// Disable NAND Flash

*GPIO_PBDR = DISABLE_CHIP;

printf("Maker Code = 0x%X\r\n",ulMakerCode);

printf("Device Code = 0x%X\r\n",ulDeviceCode);

printf("IDData = 0x%X\r\n",ulIDData);