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: 
Highlighted
Scholar ronnywebers
Scholar
1,022 Views
Registered: ‎10-10-2014

AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

according to the comments in xgpio_extra.c which is part of the driver of AXI GPIO 2.0, the funtions XGpio_DiscreteSet and XGpio_DiscreteClear have a 'Mask' parameter :

 

* @param	Mask is the set of bits that will be set to 0 in the discrete
*		data register. All other bits in the data register are
*		unaffected

to accomplish this, the functions implement a classical read-modify-write, i.e. the clear implements :

 

	Current = XGpio_ReadReg(InstancePtr->BaseAddress, DataOffset);
	Current &= ~Mask;
	XGpio_WriteReg(InstancePtr->BaseAddress, DataOffset, Current);

however, the AXI GPIO ip user guide PG144 describes the GPIO_DATA registers like this :

 

table 2-6.jpg

 

so a read-modify-write doesn't make sense IMHO ... 

 

 

But still the block diagram is confusing - looking at the block diagram, I would think that for pins configured as outputs, the values on the external pins can be read back too - however, table 2-6 says the values read from the AXI GPIO data registers will be '0' for output pins.

gpio block diagram.jpg

 

on top of that, comment in the set and clear functions says:

 

* This API can only be used if the GPIO_IO ports in the IP are used for
* connecting to the external output ports.

I tried to use the set and clear functions on a PMOD connector with a scope connected,. When stepping through the functions with the debugger, or adding some printf statements, I can clearly see that the read-modify-writes do not work as intended :

 

here's the debug code I added in the 'set' function (same for the 'clear' function)

 

	Current = XGpio_ReadReg(InstancePtr->BaseAddress, DataOffset);
	xil_printf("Step %i : DiscreteSet - mask = 0x%08x, XGpio_ReadReg returns : 0x%08x\n", stepCnt++, Mask, Current);
	Current |= Mask;
	XGpio_WriteReg(InstancePtr->BaseAddress, DataOffset, Current);

 

here is the code I execute :

 

	// set the 4 GPIO outputs 1 by 1
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000000);	// step 0
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000001);	// step 1 -> scope shows b'0001'
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000002);	// step 2 -> scope shows b'0010', but should show b'0011'
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000004);	// step 3 -> scope shows b'0100', but should show b'0111'
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000008);	// step 4 -> scope shows b'1000', but should show b'1111'

	// clear the 4 GPIO outputs 1 by 1
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000001);	// step 5 -> scope shows b'0000', but should show b'1110'
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000002);	// step 6 ...
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000004);	// step 7
	XGpio_DiscreteSet(&axiGpioPmod2, 1, 0x00000008);	// step 8

here is the result of the debug prints :

 

Step 0 : DiscreteSet - mask = 0x00000000, XGpio_ReadReg returns : 0x00000000
Step 1 : DiscreteSet - mask = 0x00000001, XGpio_ReadReg returns : 0x00000000
Step 2 : DiscreteSet - mask = 0x00000002, XGpio_ReadReg returns : 0x00000000
Step 3 : DiscreteSet - mask = 0x00000004, XGpio_ReadReg returns : 0x00000000
Step 4 : DiscreteSet - mask = 0x00000008, XGpio_ReadReg returns : 0x00000000
Step 5 : DiscreteSet - mask = 0x00000001, XGpio_ReadReg returns : 0x00000000
Step 6 : DiscreteSet - mask = 0x00000002, XGpio_ReadReg returns : 0x00000000
Step 7 : DiscreteSet - mask = 0x00000004, XGpio_ReadReg returns : 0x00000000
Step 8 : DiscreteSet - mask = 0x00000008, XGpio_ReadReg returns : 0x00000000

Q: so clearly reading the values from the AXI GPIO does not work (as spec'd in PG144 -> either this function is intedend for use with PS GPIO ? Or it should be removed from the AXI_GPIO driver to avoid confusion. Or is my whole analysis incorrect?

 

I'll be keeping track of the gpio status in a local variable and use the DiscriteWrite and DiscreteRead funtions instead. 

 

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
6 Replies
824 Views
Registered: ‎12-28-2018

Re: AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

I am also facing same problem. Kindly share  solution if you have

Scholar ronnywebers
Scholar
802 Views
Registered: ‎10-10-2014

Re: AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

@jagan.sameer I haven't solved this yet ... still waiting for an answer from Xilinx ... :-( 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Xilinx Employee
Xilinx Employee
739 Views
Registered: ‎07-12-2018

Re: AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

Hi @ronnywebers,

 

This is a typographical error in the Product Guide.

GPIO output registers cannot be read back through the AXI4Lite interface.

Best Regards
Abhinay PS
------------------------------------------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give kudos to a post which you think is helpful and reply oriented.
-------------------------------------------------------------------------------------------------------------------------------

Scholar ronnywebers
Scholar
734 Views
Registered: ‎10-10-2014

Re: AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

thanks @abhinayp, if I understand that correctly, the block diagram of the AXI GPIO seems wrong to me, as it gives the impression that the output level on the pin can be read back?

And also the methods 'XGpio_DiscreteSet' and 'XGpio_DiscreteClear' don't make any sense in the AXI GPIO driver?  If the don't work, shouldn't they be removed from the driver? however, it would be even better if the AXI GPIO IP would allow readback of the outputs, so that the discrete set and clear functions would work...

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Xilinx Employee
Xilinx Employee
727 Views
Registered: ‎02-01-2008

Re: AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

I didn't see this thread until now so hopefully I'm not stepping on any toes.

There are many ways to use the axi gpio. The read-modify-write works if the gpio has been configured as 'all outputs', or the outputs of the gpio or looped back to the inputs.

It is the above case where read-modify-write works. Otherwise, if your gpio output is not looped back, and you have not configured the gpio as 'all outputs', then the mask functions do not work and you would have to create your own software ghost registers (to keep a local copy of the last written value) and your own masking functions.

Scholar ronnywebers
Scholar
701 Views
Registered: ‎10-10-2014

Re: AXI GPIO - XGpio_DiscreteSet and XGpio_DiscreteClear conflict with PG144 specs

thanks @johnmcd for your reply.

I'm not sure if you mean the following with 'outputs of the gpio looped back to the inputs' :

gpio.jpg

so in the screenshot above, the AXI GPIO is configured as 'custom' with 'all inputs' and 'all outputs' unchecked. But when I select 'all outputs', I cannot loopback these signals :

gpio all outputs.jpg

In my design that I used for testing the DiscreteSet functions, I used the 'connection automation' to connect the AXI GPIO to the on-board LEDs (Zedboard), hence it configured the AXI GPIO as 'all outputs'. In the meantime I threw away the project, but I'm pretty sure I could not use the DiscreteSet functions, indeed I implemented a software 'shadow' register for that. 

So are you sure aobut the statement 'The read-modify-write works if the gpio has been configured as 'all outputs' ? I should recreate my project then to test this.

I think that if I uncheck 'all inputs' and 'all outputs', the read-modify-write might work indeed (?), question is do I need to 'link' output to input in the block design then. If I find the time I will definitely check this.

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos