Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

USB superspeed peripherals

UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello dears,

 

I want to set as output a GPIO but it is not working ok.

 

void
PocInit (
void)
{
CyU3PErrorCode_t status;
//CyU3PIoMatrixConfig_t ioCfg;
CyU3PGpioSimpleConfig_t gpioConfig;
CyBool_t value;
CyU3PReturnStatus_t apiRetStatus;
CyU3PGpioClock_t gpioClock;

/* Init the GPIO module */
gpioClock.fastClkDiv = 2;
gpioClock.slowClkDiv = 2;
gpioClock.simpleDiv = CY_U3P_GPIO_SIMPLE_DIV_BY_2;
gpioClock.clksrc=CY_U3P_SYS_CLK;
gpioClock.halfDiv = 0;
// apiRetStatus = CyU3PGpioInit (&gpioClock, NULL);
// if (apiRetStatus != 0)
// {
// CyU3PDebugPrint (4, "GPIO Init failed, Error Code = %d\n", apiRetStatus);
//}


status = CyU3PDeviceGpioOverride (POC_ENABLE,CyTrue);

if (status != 0){
CyU3PDebugPrint (4, "CyU3PDeviceGpioOverride failed, error code = %d\n", status);
}

 

/* Configure GPIO 18 as output;  */

gpioConfig.outValue = CyFalse;

gpioConfig.inputEn = CyFalse;;

gpioConfig.driveLowEn = CyTrue;;

gpioConfig.driveHighEn = CyTrue;;

gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;

status = CyU3PGpioSetSimpleConfig(18, &gpioConfig);

if (status != CY_U3P_SUCCESS)

{

CyU3PDebugPrint (4, "CyU3PGpioSetSimpleConfig failed, error code = %d\n", status);

}
status = CyU3PGpioSetValue(18, CyTrue);
if (status != CY_U3P_SUCCESS)

{

CyU3PDebugPrint (4, "CyU3PGpioSetValue failed, error code = %d\n", status);

}
}

 

If I don't use the apiRetStatus = CyU3PGpioInit (&gpioClock, NULL); this function return error status = CyU3PGpioSetSimpleConfig(18, &gpioConfig);

and if I use this function it restart my PCB . this is my main function: 

int main (void)
{
CyU3PIoMatrixConfig_t io_cfg;
CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

/* Initialize the device */
CyU3PSysClockConfig_t clockConfig;
clockConfig.setSysClk400 = CyFalse;
clockConfig.cpuClkDiv = 2;
clockConfig.dmaClkDiv = 2;
clockConfig.mmioClkDiv = 2;
clockConfig.useStandbyClk = CyFalse;
clockConfig.clksrc=CY_U3P_SYS_CLK;

status = CyU3PDeviceInit (&clockConfig);
if (status != CY_U3P_SUCCESS)
{
goto handle_fatal_error;
}

/* Initialize the caches. Enable instruction cache and keep data cache disabled.
* The data cache is useful only when there is a large amount of CPU based memory
* accesses. When used in simple cases, it can decrease performance due to large
* number of cache flushes and cleans and also it adds to the complexity of the
* code. */
status = CyU3PDeviceCacheControl (CyTrue, CyFalse, CyFalse);
if (status != CY_U3P_SUCCESS)
{
goto handle_fatal_error;
}

/* Configure the IO matrix for the device.*/
io_cfg.isDQ32Bit = CyFalse;
io_cfg.useUart = CyTrue;
io_cfg.useI2C = CyTrue;
io_cfg.useI2S = CyFalse;
io_cfg.useSpi = CyFalse;
#ifndef FX3_STREAMING
io_cfg.lppMode = CY_U3P_IO_MATRIX_LPP_DEFAULT;
#else
io_cfg.lppMode = CY_U3P_IO_MATRIX_LPP_UART_ONLY;
#endif

/* No GPIOs are enabled. */
io_cfg.gpioSimpleEn[0] = 0;
io_cfg.gpioSimpleEn[1] = 0;
io_cfg.gpioComplexEn[0] = 0;
io_cfg.gpioComplexEn[1] = 0;
status = CyU3PDeviceConfigureIOMatrix (&io_cfg);
if (status != CY_U3P_SUCCESS)
{
goto handle_fatal_error;
}
PocInit();
/* This is a non returnable call for initializing the RTOS kernel */
CyU3PKernelEntry ();

/* Dummy return to make the compiler happy */
return 0;

handle_fatal_error:
/* Cannot recover from this error. */
while (1);
}

 

 

Thank you

0 Likes
1 Solution
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

For initializing  GPIO in CX3 firmware, this CyU3PMipicsiInitializeGPIO() API has to be called, instead of CyU3PGpioInit(). Kindly replace CyU3PGpioInit(..) API with CyU3PMipicsiInitializeGPIO(..) in your firmware

Best Regards,
AliAsgar

View solution in original post

0 Likes
13 Replies
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

There exists a GpioApp firmware example for driving GPIO's in the FX3 SDK, which is tested successfully. Please refer to that firmware example.
Also it would be better if you could share with us your firmware project folder.

Best Regards,
AliAsgar

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello,

 

I also use the GPIOAPP example but is not working.

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello,

I would like to implement this example on my PCB, on my PCB there is CYUSB306X, and DS90UB960 deserializer with Omnivision camera Ox03A10, to do that I have to set this GPIO 18 as output, this is the POC GPIO because the POC is  integrated on the PCB, this is the code I use, thanks for the help. where could I make the necessary settings to take a picture/video like this example? thank you

0 Likes
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

Could you check and let us know the return status of CyU3PGpioInit() API in your firmware.

Best Regards,
AliAsgar

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello dear AliAsgar,

I don't know why I can't debug this example.

 

 

0 Likes
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

Could you give more information on when the load is failing?
Could you let us know the return status of CyU3PGpioInit(..) API by using a debug print?

Best Regards,
AliAsgar

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

 

Hello,

This is my return status of CyU3PGpioInit().

 

Petra_0-1623310044304.png

 

0 Likes
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

We need the return status of the GpioInit(..) API call after the firmware is loaded on the FX3. Kidnly follow the below steps:
Please find the attached project folder. Build the project and program FX3 with the image file. Please  share the debug prints with us. 

Best Regards,
AliAsgar

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello AliAsgar,

All in my function PocInit() looks ok.

Petra_0-1623390774671.png

why do you think it still doesn't work? what should I change ?

 

thank you

 

 

0 Likes
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

For initializing  GPIO in CX3 firmware, this CyU3PMipicsiInitializeGPIO() API has to be called, instead of CyU3PGpioInit(). Kindly replace CyU3PGpioInit(..) API with CyU3PMipicsiInitializeGPIO(..) in your firmware

Best Regards,
AliAsgar

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello AliAsgar,

 

my example still doesn't work? can you set with this PocInit() function example a GPIO less than 30? Or, can you give me a function that is working fine? thank you

0 Likes
AliAsgar
Moderator
Moderator 500 replies posted 250 replies posted 250 sign-ins
Moderator

Hello,

Kindly refer to page no. 15 of this datasheet  for the list of available GPIOs .

Also please refer to the CX3 firmware example projects in the FX3 SDK on initialization and usage of GPIOs.

Best Regards,
AliAsgar

0 Likes
UserP1994
Level 3
10 replies posted 10 questions asked 10 sign-ins
Level 3

Hello AliAsgar,

 

My example is working fine.

 

Thank you.

0 Likes