- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello , I have a question about the GPIO operation.
Now , my firmware is Slave Fifo, as well as I also hope to use "CCyControlEndPoint" to transfer one byte(command) in order to change the voltage of GPIO45.
For instance, transfer "0" to pull the GPIO45 to low or "255" to push it to high. After the command is conducted, the state of GPIO45 only can be changed until the next command coming.
Then I insert three part of code like this :
void
CyFxGpioInit (void)
{
CyU3PGpioClock_t gpioClock;
CyU3PGpioSimpleConfig_t gpioConfig;
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
gpioClock.fastClkDiv = 2;
gpioClock.slowClkDiv = 0;
gpioClock.simpleDiv = CY_U3P_GPIO_SIMPLE_DIV_BY_2;
gpioClock.clkSrc = CY_U3P_SYS_CLK;
gpioClock.halfDiv = 0;
apiRetStatus = CyU3PGpioInit(&gpioClock, CyFxGpioIntrCb);
apiRetStatus = CyU3PDeviceGpioOverride (45, CyTrue);
/* Configure GPIO 45 as output */
gpioConfig.outValue = CyTrue;
gpioConfig.driveLowEn = CyTrue;
gpioConfig.driveHighEn = CyTrue;
gpioConfig.inputEn = CyFalse;
gpioConfig.intrMode = CY_U3P_GPIO_NO_INTR;
apiRetStatus = CyU3PGpioSetSimpleConfig(45, &gpioConfig);
}
void CyFxGpioIntrCb (
uint8_t gpioId /* Indicates the pin that triggered the interrupt */
)
{
CyBool_t gpioValue = CyFalse;
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
/* Get the status of the pin */
apiRetStatus = CyU3PGpioGetValue (gpioId, &gpioValue);
if (apiRetStatus == CY_U3P_SUCCESS)
{
/* Check status of the pin */
if (gpioValue == CyTrue)
{
/* Set GPIO high event */
CyU3PEventSet(&glFxGpioAppEvent, CY_FX_GPIOAPP_GPIO_HIGH_EVENT,
CYU3P_EVENT_OR);
}
else
{
/* Set GPIO low Event */
CyU3PEventSet(&glFxGpioAppEvent, CY_FX_GPIOAPP_GPIO_LOW_EVENT,
CYU3P_EVENT_OR);
}
}
}
CyBool_t
CyFxSlFifoApplnUSBSetupCB (
uint32_t setupdat0,
uint32_t setupdat1
)
{
*************
else if (bRequest == CY_FX_USB_UART_SET_CUR_REQ)
{
/* Get the UART data from EP0 */
status = CyU3PUsbGetEP0Data (CY_FX_UART_MAX_BUFFER_SIZE, glUartTxBuffer, &readCount);
if (status == CY_U3P_SUCCESS)
{
/* Send the byte */
CyU3PUartTransmitBytes (glUartTxBuffer, readCount, &status);
if (status != CY_U3P_SUCCESS)
{
}
}
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
if(glUartTxBuffer == 255)
{
apiRetStatus = CyU3PGpioSetValue (45, CyTrue);
}
else if(glUartTxBuffer == 0)
{
apiRetStatus = CyU3PGpioSetValue (45, CyFalse);
}
*************
}
However, when I send '0' byte via "CCyControlEndPoint" , the voltage of GPIO shifts to 0V and back to 3.3V /2 immediately , while I send '255' and it shifts to 3.3V and back to 3.3V/2 as well. In other words, the state of GPIO45 can not stay 'high' or 'low' steadily .
I hope it could be monostable, so could you point out what the problem is ??
thank you very much!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please ensure that your I/O power domains are properly supplied with constant 3.3V supply.
Alternatively, please try using the CyU3PGpioSetIoMode(45,1); to set the GPIO, and CyU3PGpioSetIoMode(45,2); to set the GPIO 45 to low.
Check if this too showed the same behaviour and let us know.
Regards,
-Madhu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello MADY, the above questions have been tested again and the current problem is:
1) The 3.3V/2 problem is from my oscilloscope , now this problem is fixed
2) I have measure the voltage of GPIO45 after "CyU3PGpioSetValue (45, CyTrue)" conducted.
The voltage of it goes to 3.3V for 1us after the above command , and then the voltage back to 0V.
I also tried to use CyU3PGpioSetIoMode but it does not work at all.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I guess that "glUartTxBuffer" is pointer (because CyU3PUsbGetEP0Data expects the second parameter to be pointer).
You check the pointer value:
if(glUartTxBuffer == 255)
and
if(glUartTxBuffer == 0)
I believe both results are false, so the CyU3PGpioSetValue is never called. How the GPIO 45 gan go to high for 1us?
br,
kalev