cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

Anonymous
Not applicable

I am able to generate PWM from GPIO26 but not on GPIO27.

conditions we applied,

1. 10KHZ PWM ( CY_FX_PWM_PERIOD  (20160 - 1)   /* PWM time period. */

2. We divided this into 255 steps

we receive input from the host application using sensorset brightness function

Eg:  a = input * 790.5

Then we do

apiRetStatus = CyU3PGpioComplexUpdate (CY_FX_PWM_GPIO,

                               (a-1), CY_FX_PWM_PERIOD);

The issue I am facing now is  when the input value is changed gradually the PWM response is giving the exact output what we want. If I move the slider fast or sudden change in two to five times the output gets inverted.

for eg:

if I give 10 input then the on time should be low and off time should large but in our case its reversed. this output happens when we move the slider fast. After sometimes it will be back to normal.

I tried changing the pin GPIO50 . I observed the same condition. I have followed the example program from the sdk (GPIOCOMPLEXAPP) and merged this code with UVC application to control the led brightness. Kindly suggest a solution for the issue.

Thanks in advance

0 Likes
1 Solution
Hemanth
Moderator
Moderator

Hi Nivin,

To avoid the inversion on GPIO_26 please do the following in your code:

1. Declare pointers to the following GPIO registers as shown below:

uvint32_t *gpio_26_status_register      = (uvint32_t*) 0xE0001020;

uvint32_t *gpio_26_threshold_register = (uvint32_t*) 0xE000102C;

2. Remove the CyU3PGpioComplexUpdate() API that you are calling in your code and replace it

with the following snippet:

*gpio_26_status_register    &= 0x7FFFFFFF;                     // Disable the GPIO 26

*gpio_26_threshold_register = threshold_update_value;    // Set New Threshold

*gpio_26_status_register    &= 0xFFFFFFFE;                     // Set Default value as 0

*gpio_26_status_register     |= (1u<<31);                             // Enable back the GPIO 26

By doing this, the inversion doesn't occur.

Note: The above register addresses are related only to GPIO_26 configured as complex GPIO.

Regards,

Hemanth

Hemanth

View solution in original post

0 Likes
2 Replies
Anonymous
Not applicable

The system clock frequency is 416 MHz, clocked using 26 MHz crystal.

0 Likes
Hemanth
Moderator
Moderator

Hi Nivin,

To avoid the inversion on GPIO_26 please do the following in your code:

1. Declare pointers to the following GPIO registers as shown below:

uvint32_t *gpio_26_status_register      = (uvint32_t*) 0xE0001020;

uvint32_t *gpio_26_threshold_register = (uvint32_t*) 0xE000102C;

2. Remove the CyU3PGpioComplexUpdate() API that you are calling in your code and replace it

with the following snippet:

*gpio_26_status_register    &= 0x7FFFFFFF;                     // Disable the GPIO 26

*gpio_26_threshold_register = threshold_update_value;    // Set New Threshold

*gpio_26_status_register    &= 0xFFFFFFFE;                     // Set Default value as 0

*gpio_26_status_register     |= (1u<<31);                             // Enable back the GPIO 26

By doing this, the inversion doesn't occur.

Note: The above register addresses are related only to GPIO_26 configured as complex GPIO.

Regards,

Hemanth

Hemanth

View solution in original post

0 Likes