UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor begleysm
Visitor
2,019 Views
Registered: ‎08-12-2008

Trouble using XGpio_ReadReg for 16-bit Flash

Hello everyone,

 

I have a 16-bit flash part connected to an EDK project via an xps_mch_emc IP instance.  I am trying to use the new XGpio_WriteReg and XGpio_ReadReg functions in EDK 12.1.  Below is the original code snippet for a 16 bit read function that works correctly.  It uses the XIo_In16 function.

 

 

Xuint16
read_flash_data(Xuint32 ui_raddr)
{
	while (flash_busy())
	{
		// wait
		//print("Waiting for flash to no longer be busy\r\n");
	}

	return XIo_In16(FLASH_ADDR + (ui_raddr << 1));
}

 

 

Which gives the following (correct) output.

 

 

Erasing flash...     DONE.

Printing 20 words starting at word address 0x0
0:      FFFF
1:      FFFF
2:      FFFF
3:      FFFF
4:      FFFF
5:      FFFF
6:      FFFF
7:      FFFF
8:      FFFF
9:      FFFF
A:      FFFF
B:      FFFF
C:      FFFF
D:      FFFF
E:      FFFF
F:      FFFF
10:     FFFF
11:     FFFF
12:     FFFF
13:     FFFF

Writing numerically increasing data to flash
        Writing 0x0 to address 0x0
        Writing 0x1 to address 0x1
        Writing 0x2 to address 0x2
        Writing 0x3 to address 0x3
        Writing 0x4 to address 0x4
        Writing 0x5 to address 0x5
        Writing 0x6 to address 0x6
        Writing 0x7 to address 0x7
        Writing 0x8 to address 0x8
        Writing 0x9 to address 0x9
        Writing 0xA to address 0xA
        Writing 0xB to address 0xB
        Writing 0xC to address 0xC
        Writing 0xD to address 0xD
        Writing 0xE to address 0xE
        Writing 0xF to address 0xF
        Writing 0x10 to address 0x10
        Writing 0x11 to address 0x11
        Writing 0x12 to address 0x12
        Writing 0x13 to address 0x13

Done.

Printing 20 words starting at word address 0x0
0:      0
1:      1
2:      2
3:      3
4:      4
5:      5
6:      6
7:      7
8:      8
9:      9
A:      A
B:      B
C:      C
D:      D
E:      E
F:      F
10:     10
11:     11
12:     12
13:     13

 

 

When I modify the read function to use XGpio_ReadReg (like so)

 

 

Xuint16
read_flash_data(Xuint32 ui_raddr)
{
	while (flash_busy())
	{
		// wait
		//print("Waiting for flash to no longer be busy\r\n");
	}

	return (Xuint16) XGpio_ReadReg(FLASH_ADDR, ui_raddr << 1);
}

 

 

I get the following (incorrect) output

 

 

Erasing flash...     DONE.

Printing 20 words starting at word address 0x0
0:      FFFF
1:      FFFF
2:      FFFF
3:      FFFF
4:      FFFF
5:      FFFF
6:      FFFF
7:      FFFF
8:      FFFF
9:      FFFF
A:      FFFF
B:      FFFF
C:      FFFF
D:      FFFF
E:      FFFF
F:      FFFF
10:     FFFF
11:     FFFF
12:     FFFF
13:     FFFF

Writing numerically increasing data to flash
        Writing 0x0 to address 0x0
        Writing 0x1 to address 0x1
        Writing 0x2 to address 0x2
        Writing 0x3 to address 0x3
        Writing 0x4 to address 0x4
        Writing 0x5 to address 0x5
        Writing 0x6 to address 0x6
        Writing 0x7 to address 0x7
        Writing 0x8 to address 0x8
        Writing 0x9 to address 0x9
        Writing 0xA to address 0xA
        Writing 0xB to address 0xB
        Writing 0xC to address 0xC
        Writing 0xD to address 0xD
        Writing 0xE to address 0xE
        Writing 0xF to address 0xF
        Writing 0x10 to address 0x10
        Writing 0x11 to address 0x11
        Writing 0x12 to address 0x12
        Writing 0x13 to address 0x13

Done.

Printing 20 words starting at word address 0x0
0:      1
1:      1
2:      3
3:      3
4:      5
5:      5
6:      7
7:      7
8:      9
9:      9
A:      B
B:      B
C:      D
D:      D
E:      F
F:      F
10:     11
11:     11
12:     13
13:     13

 

 

According to the comments for XGpio_ReadReg it should work for widths narrower then 32 bits by performing a 16 bit read and setting the top (extra) 16 bits to 0.

 

Why doesn't this work?  How do I need to modify my code to make it work?

 

Thanks,

Sean

 

 

0 Kudos