cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
shahed.siddiqui
Visitor
Visitor
4,431 Views
Registered: ‎11-29-2016

How to write to and read from ZC702 PMOD2 GPIO pins from FreeRTOS running on remote processor

Using ZC702. Running Linux on local processor and FreeRTOS on remote processor. Using openAMP. Successfully ran echo test.

 

Added DS23 LED blinking code to FreeRTOS task using XGpioPs and pin 10:

#include "xgpiops.h"
#define GPIO_DEVICE_ID XPAR_XGPIOPS_0_DEVICE_ID
#define OUTPUT_PIN 10

void prvSetGpioHardware(int Value);
void prvLed_Toggle (int Value);
XGpioPs Gpio;
XGpioPs_Config *ConfigPtr;
int gpioState;

 

void prvSetGpioHardware(int Value)
{
/*
* Initialize the GPIO driver.
*/
ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);
XGpioPs_CfgInitialize(&Gpio, ConfigPtr, ConfigPtr->BaseAddr);
/*
* Set the direction for the pin to be output and
* Enable the Output enable for the LED Pin.
*/
XGpioPs_SetDirectionPin(&Gpio, OUTPUT_PIN, 1);
XGpioPs_SetOutputEnablePin(&Gpio, OUTPUT_PIN, 1);
/*
* Set the GPIO output to be gpioState.
*/
XGpioPs_WritePin(&Gpio, OUTPUT_PIN, Value);
}


void prvLed_Toggle (int Value)
{
int Data;
/*
* Set the GPIO Output to Value.
*/
XGpioPs_WritePin(&Gpio, OUTPUT_PIN, Value);
/*
* Read the state of the data and verify. If the data
* read back is not the same as the data written then
* return FAILURE.
*/
Data = XGpioPs_ReadPin(&Gpio, OUTPUT_PIN);
if (Data != Value ) {
xil_printf("shaheds:Pin Data=%d != Value=%d \r\n", Data, Value);
}
}

 

Added code to "processing" loop that gets called repeatedly to echo test message from Linux side via openAMP messaging:

gpioState = gpioState ^ 0x01;
prvLed_Toggle(gpioState);

 

Added code to main():

gpioState = 0;
prvSetGpioHardware(gpioState);

 

Added following code to system-top.dts:

&amba {
gpio-leds {
compatible="gpio-leds";
led-user8 {
label="led-user8";
gpios=<&gpio0 8 0>;
default-state = "off";
};
led-user10 {
label="led-user10";
gpios=<&gpio0 10 0>;
default-state = "off";
};
led-user11 {
label="led-user11";
gpios=<&gpio0 11 0>;
default-state = "off";
};
led-user15 {
label="led-user15";
gpios=<&gpio0 15 0>;
default-state = "off";
};
};
};

 

I DO SEE DS23 LED TOGGLING USING PIN=10 in FreeRTOS code.

I CANNOT ACCESS ANY OTHER PINS -- such as PMOD2_0,1,2,3.

I also cannot toggle any other LEDs.

What is the solution? Thanks.

0 Kudos
1 Reply
balkris
Xilinx Employee
Xilinx Employee
4,401 Views
Registered: ‎08-01-2008

check these links
https://www.xilinx.com/support/answers/51786.html
http://www.powellprojectshowcase.com/projects/thesis-zynq/1introductiontothehardwareanddevelopmentenvironments
http://www.srns.ru/mediawiki/images/d/d3/Xtp185-zc702-schematic-rev1-1.pdf
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
0 Kudos