|
Hi Swee Huei,
Looking at your code, the following areas can be looked into:
1) The Period1, Compare1, Period2 and Compare2 can be declared as unsigned integer of 8 or 16 bits (uint8 or uint16) depending upon the resolution of the PWM components used.
2) The variable which holds the duty cycle value, duty1 and duty2 can then be typecasted to float while computation.
3) Duty cycle computation depends upon the Compare type. If you are using Compare type of "Less", then duty cycle will be (Compare / (Period + 1)) * 100
4) Instead of printing the duty1 and duty2 directly, you need to first convert the floating point number into an array which can then be printed on LCD. For this you can use sprintf function as shown below:
duty1_string[6];
char
"%2.2f", duty1);/* Floating point number is converted to decimal point format for display */
sprintf(duty1_string,
CharLCD_1_PrintString(duty1_string);
Let us know if this works.
|