Not applicable
Jul 19, 2013
11:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 19, 2013
11:18 PM
Hi, Anyone know how to set compare value in PWM apps?
especially in programming C parts.
Thanks guys,
Regards,
Ali
especially in programming C parts.
Thanks guys,
Regards,
Ali
- Tags:
- IFX
3 Replies
Jul 21, 2013
01:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 21, 2013
01:11 PM
Please read the API definitions of the documentation of the respective PWM App that can be found in the Help Contents.
You can find them in the Help menu: ->Help Contents then open the Content section DAVE Apps.
There you can find a list of all DAVE App documents in alphabetical order of all DAVE Apps that are installed in the local library store. The documents are versioned associated to the version of the DAVE App.
Below, the API description plus example code to change the compare register when using PWMSP001 App.
You can find them in the Help menu: ->Help Contents then open the Content section DAVE Apps.
There you can find a list of all DAVE App documents in alphabetical order of all DAVE Apps that are installed in the local library store. The documents are versioned associated to the version of the DAVE App.
Below, the API description plus example code to change the compare register when using PWMSP001 App.
status_t PWMSP001_SetCompare ( const PWMSP001_HandleType * HandlePtr,
uint32_t Compare
)
This function will update the duty cycle of the output waveform.
Duty cycle is given in terms of the compare register value and not in terms of the percentage.
Parameters:
[in] HandlePtr Pointer to PWMSP001_HandleType structure
[in] Compare Compare register value
Returns:
status_t
DAVEApp_SUCCESS: if function is successful
PWMSP001_OPER_NOT_ALLOWED_ERROR: If this function is called when in the state PWMSP001_UNINTIALIZED.
Reentrancy: Yes
Sync/Async: Synchronous
#include
int main(void)
{
status_t Status;
uint32_t Counter;
DAVE_Init();
//Start needs to be called only when "Start after initialization" is not checked
Status = PWMSP001_Start((PWMSP001_HandleType*)&PWMSP001_Handle0);
// Wait to observe the waveform
for(Counter = 0;Counter <=0xFFFF;Counter++);
// Change compare register value
// CR = 2500
Status = PWMSP001_SetCompare((PWMSP001_HandleType*)&PWMSP001_Handle0, 2500);
for(Counter = 0;Counter <=0xFFFF;Counter++);
while(1);
return 0;
}
Not applicable
Jul 22, 2013
01:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 22, 2013
01:04 AM
Hi Georg Cuba,
Thanks for the replied,
I try the code like this:
DutyPtr.CompReg[0]= 1;
DutyPtr.CompReg[1]= 2;
DutyPtr.CompReg[2]= 1;
DutyPtr.CompReg[3]= 2;
PWMMP001_SetCompare(&PWMMP001_Handle0,&DutyPtr);
but when i observe in oscilloscope, it doesn't generate a signal, or zero signal resulting.
do you know whats wrong with the code?
Thanks for the replied,
I try the code like this:
DutyPtr.CompReg[0]= 1;
DutyPtr.CompReg[1]= 2;
DutyPtr.CompReg[2]= 1;
DutyPtr.CompReg[3]= 2;
PWMMP001_SetCompare(&PWMMP001_Handle0,&DutyPtr);
but when i observe in oscilloscope, it doesn't generate a signal, or zero signal resulting.
do you know whats wrong with the code?
Jul 22, 2013
08:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 22, 2013
08:14 PM
Hi,
You have enter the wrong parameter.
status_t PWMSP001_SetCompare ( const PWMSP001_HandleType * HandlePtr, uint32_t Compare )
First parameter is the pointer to the handle
Second parameter is the compare value.
Please use the example provided by Georg
Status = PWMSP001_SetCompare((PWMSP001_HandleType*)&PWMSP00 1_Handle0, 2500);
*Take note that the period value need to be larger than "2500".
You have enter the wrong parameter.
status_t PWMSP001_SetCompare ( const PWMSP001_HandleType * HandlePtr, uint32_t Compare )
First parameter is the pointer to the handle
Second parameter is the compare value.
Please use the example provided by Georg
Status = PWMSP001_SetCompare((PWMSP001_HandleType*)&PWMSP00 1_Handle0, 2500);
*Take note that the period value need to be larger than "2500".