pwm cx3 complexgpioupdateapi problem

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

cross mob
clinton
Level 2
Level 2
First solution authored 5 questions asked 25 sign-ins

Hi I am generating pwm duty cycle with cx3 chip 
previously i used complexupdate api it has some proble its not reflecting the values 
Then i accessed register for updating the threshold value every time i changed the duty cycle the problem is when duty cycle changed to 100 perc its reflecting in dso as 50 percent can any one have idea on it  

Thanks in advance

Best Regards

Clinton

0 Likes
1 Solution
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Clinton,

Considering with gpioConfig.timer = 0,
For 100% PWM, set the threshold value to one less than the period value. This should give a virtually 100% PWM. Ex;

gpioConfig.period = CY_FX_PWM_PERIOD;
gpioConfig.threshold = CY_FX_PWM_PERIOD - 1;

For 0% PWM, set the threshold value to 2. This should give virtually a 0% PWM.

Best Regards,
AliAsgar

View solution in original post

0 Likes
5 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Clinton,

Could you let us know if the duty cycle is 100% if the complexUpdate API is used?

What is the implementation to access and change the register values? Please share code snippet.

Best Regards,
AliAsgar

 

0 Likes

if((wIndex == 0x200) && (wValue == 0x200))/*FREQUENCY IN HZ*/
{
switch(bRequest)
{
case CX3_USB_UVC_GET_INFO_REQ:
glGet_Info=0x03;
status = CyU3PUsbSendEP0Data(1,&glGet_Info);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\r cx3 rdk sendendpoint0 fail = %d", status);
}
break;
case CX3_USB_UVC_GET_MIN_REQ:
gl16GetControl=1;
status = CyU3PUsbSendEP0Data(2,(uint8_t*)&gl16GetControl);
break;
case CX3_USB_UVC_GET_MAX_REQ:
gl16GetControl=10;
status = CyU3PUsbSendEP0Data(2,(uint8_t*)&gl16GetControl);
break;
case CX3_USB_UVC_GET_RES_REQ:
gl16GetControl=1;
break;
case CX3_USB_UVC_GET_CUR_REQ:
case CX3_USB_UVC_GET_DEF_REQ:
gl16GetControl=glfrequency;


status = CyU3PUsbSendEP0Data(2,(uint8_t*)&gl16GetControl);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSB Cx3 rdk StpCB:VCI SendEP0Data = %d", status);
}
break;
case CX3_USB_UVC_SET_CUR_REQ:
status = CyU3PUsbGetEP0Data(16,(uint8_t*)&gl16SetControl,&readCount);
if (status != CY_U3P_SUCCESS)
{
CyU3PDebugPrint (4, "\n\rUSB Cx3 rdk StpCB:VCI SendEP0Data = %d", status);
}

glfrequency = (uint8_t)gl16SetControl;

frequency_ticks = CY_FX_PWM_PERIOD/(glfrequency);

  • threshold_ticks = (frequency_ticks * gldutycycle/100);
    gpioConfig.period= frequency_ticks;
    gpioConfig.threshold = threshold_ticks;
0 Likes
clinton
Level 2
Level 2
First solution authored 5 questions asked 25 sign-ins

HI @AliAsgar  
I want to change from complex to simplex and vice versa in order to solve for 0 percent duty cycle its should blank in dso but actually its not

So in cx3 there is proble if we generate a pwm wave with 100 perc and 0 perc its comming around 50 %dutycycle if eventhough i hardcoded for 0 percent duty cycle its comming around 50 perc 

Best regards

clinton

0 Likes
lock attach
Attachments are accessible only for community members.

Hi @AliAsgar  I am attaching the file i share the password through privtae mode

for generating the duty cycle of 0  and 100 percent i used overide gpio function for  zero percent duty cycle i set it too low  the gpio and for 100 i set to high the gpio still when i do like that for 100 its showing  99% and for zero its showing 1% 


BestRegards

clinton

0 Likes
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Clinton,

Considering with gpioConfig.timer = 0,
For 100% PWM, set the threshold value to one less than the period value. This should give a virtually 100% PWM. Ex;

gpioConfig.period = CY_FX_PWM_PERIOD;
gpioConfig.threshold = CY_FX_PWM_PERIOD - 1;

For 0% PWM, set the threshold value to 2. This should give virtually a 0% PWM.

Best Regards,
AliAsgar

0 Likes