PIC16f887 start and start pwm

Discussion in 'Embedded Systems and Microcontrollers' started by Tamim Neak, Feb 23, 2015.

  1. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    hi all i have the following code and i am trying to make the pwm run only when a specified pin is high example PORTB.F0 = 1; so far i have been unsuccessful. can anyone help please?


    Code (Text):
    1. unsigned char sin_table[64]={0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 59, 64, 69, 74, 79, 84, 88, 93, 97, 100, 104, 107, 110, 113, 115, 118, 120, 121, 123, 124, 124, 125, 125, 125, 124, 124, 123, 121, 120, 118, 115, 113, 110, 107, 104, 100, 97, 93, 88, 84, 79, 74, 69, 64, 59, 53, 48, 42, 36, 30, 24, 18, 12, 6};
    2. unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
    3. unsigned int TBL_temp;
    4. unsigned char DUTY_CYCLE;
    5. void interrupt(){
    6. if (TMR2IF_bit == 1){
    7. TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
    8. if (TBL_POINTER_NEW < TBL_POINTER_OLD){
    9. CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
    10. }
    11. TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10;
    12. DUTY_CYCLE = TBL_POINTER_SHIFT;
    13. CCPR1L = sin_table[DUTY_CYCLE];
    14. TBL_POINTER_OLD = TBL_POINTER_NEW;
    15. TMR2IF_bit = 0;
    16. }
    17. }
    18. void main() {
    19. SET_FREQ = 1024;
    20. TBL_POINTER_SHIFT = 0;
    21. TBL_POINTER_NEW = 0;
    22. TBL_POINTER_OLD = 0;
    23. DUTY_CYCLE = 0;
    24. ANSEL = 0; //Disable ADC
    25. CM1CON0 = 0; //Disable Comparator
    26. CM2CON0 = 0;
    27. TRISC.F2 = 0;
    28. TRISD.F5 = 0;
    29. TRISD.F6 = 0;
    30. TRISD.F7 = 0;
    31. TRISC.F0 = 1;
    32. TRISC.F1 = 1;
    33. PORTC.F2 = 0;
    34. PORTD.F5 = 0;
    35. PORTD.F6 = 0;
    36. PORTD.F7 = 0;
    37. PR2 = 0b01111100;
    38. CCP1CON = 0b01001100; // duty lowest bits + PWM mode
    39. TMR2IF_bit = 0;
    40. T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
    41. while (TMR2IF_bit == 0);
    42. TMR2IF_bit = 0;
    43. TRISC = 0;
    44. TMR2IE_bit = 1;
    45. GIE_bit = 1;
    46. PEIE_bit = 1;
    47. while(1);
    48. }
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Without going through the code in detail, if the PWM is working as required I'd do something like:

    1)Split off the PWM initialization and start up into its own self-contained function. Call it startPWM() or something like that..
    2) Write a new function that turns off the PWM (timer off, interrupt enable off etc) called stopPWM().
    Make sure these two functions work and control the PWM in a consistent manner with a smooth shutdown/startup.

    For control, all you have to do is expand the while(1) at the end of the code with a loop that samples the input and controls the PWM accordingly:

    Code (Text):
    1.  
    2. void initPWM(void)
    3. {
    4.  // code to setup the timer, duty cycle, IO, table pointer init etc. Leaves PWM off but ready to run
    5. }
    6. void startPWM(void)
    7. {
    8.   // code to start the pre-configured PWM
    9. }
    10.  
    11. void stopPWM(void)
    12. {
    13.  // code to stop the PWM, preserving its configuration
    14. }
    15. //***** in main, after init IO etc..  *******************
    16.    initPWM(); // set up PWM values so that startPWM and stopPWM can control it.
    17.         //Leave PWM off
    18.  
    19. while(1){
    20.     while (PORTB.F0 == 0);  // wait for control to ON
    21.  
    22.     startPWM();    // turn PWM on
    23.  
    24.     while (PORTB.F0 == 1);  wait for control to OFF
    25.  
    26.     stopPWM(); // turn PWM off
    27.  
    28.     }// while
    This example doesn't do things like debounce the input etc. but is a starting point.

    A few other points:
    Don't set up your TRIS registers as individual bits - do it as a byte-write i.e. TRISB = 0bxxxxxxxx; Individual bit flipping on TRIS can be problematic.
    You don't have to do the wait for TMR2 after configuring it. Do all the config with the timer OFF then clear TMR2IF, enable the interrupts then turn the timer ON.

    Good Luck.
     
  3. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    I don't see where you are detecting tha value of the pin.

    And the whole purpose of the code tag is to preserve the tabs. No tabs makes your code very hard to read.
     
  4. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    i have tried everything i could think of and please excuse my limited coding knowledge. The code is not mine i have adjusted it to serve my purpose. if you could please provide more help it would be appreciated.
     
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    You first need to understand what you have and what you want to do. For example I see a timer interrupt code in there. What is the purpose of that code?
     
  6. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    it is to call each value of the table (sin_table) four times. this is done so because i wanted a sinewave of 60Hz generated with pwm frequency of 16KHz.
     
  7. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
  9. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    i have done that i also tried the method suggested by johninTx. i have exhausted all my resources which brings me to the reason why i posted my problem in this forum.
     
  10. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Since you copied code from the internet, have you taken the time to understand how it works?

    Post your revised code that shows the new PCM control functions and how you call them in response to the input. We can go from there.
     
  11. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015

    So you just want an answer but aren't willing to learn? Sorry but I do not think we can help you.

    Break your project into small pieces. Write a program that does nothing but read input from a pin. The link I provided will help you to understand how to do that.
     
  12. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    Code (Text):
    1. unsigned char sin_table[64]={0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 59, 64, 69, 74, 79, 84, 88, 93, 97, 100, 104, 107, 110, 113, 115, 118, 120, 121, 123, 124, 124, 125, 125, 125, 124, 124, 123, 121, 120, 118, 115, 113, 110, 107, 104, 100, 97, 93, 88, 84, 79, 74, 69, 64, 59, 53, 48, 42, 36, 30, 24, 18, 12, 6};   //100% duty cycle
    2.  
    3. unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
    4. unsigned int TBL_temp;
    5. unsigned char DUTY_CYCLE;
    6.  
    7. void interrupt(){
    8. if (TMR2IF_bit == 1){
    9. TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
    10. if (TBL_POINTER_NEW < TBL_POINTER_OLD){
    11. CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
    12.                                         }
    13. TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10;
    14. DUTY_CYCLE = TBL_POINTER_SHIFT;
    15. CCPR1L = sin_table[DUTY_CYCLE];
    16. TBL_POINTER_OLD = TBL_POINTER_NEW;
    17. TMR2IF_bit = 0;
    18.                 }
    19. }
    20. void Run_PWM(){
    21. SET_FREQ = 1024;
    22. TBL_POINTER_SHIFT = 0;
    23. TBL_POINTER_NEW = 0;
    24. TBL_POINTER_OLD = 0;
    25. DUTY_CYCLE = 0;
    26. PR2 = 0b01111100; //124
    27. CCP1CON = 0b01001100; // duty lowest bits + PWM mode
    28. TMR2IF_bit = 0;
    29. T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
    30. while (TMR2IF_bit == 0);
    31. TMR2IF_bit = 0;
    32. TRISC = 0;
    33. TMR2IE_bit = 1;
    34. GIE_bit = 1;
    35. PEIE_bit = 1;
    36. }
    37.  
    38.  
    39. void main() {
    40. ANSEL = 0; //Disable ADC
    41. CM1CON0 = 0; //Disable Comparator
    42. CM2CON0 = 0;
    43. TRISC.F2 = 0;
    44. TRISD.F5 = 0;
    45. TRISD.F6 = 0;
    46. TRISD.F7 = 0;
    47. TRISB.F0 = 1;
    48. PORTC.F2 = 0;
    49. PORTD.F5 = 0;
    50. PORTD.F6 = 0;
    51. PORTD.F7 = 0;
    52. PORTB.F0 = 1;
    53.  
    54. while (PORTB.F0 = 1) {
    55.   Run_PWM();
    56. }
    57.  
    58. while(1);
    59. }
    60.  
    I have tried running it using if and do while functions but as soon as i put the run_pwm() inside a loop in the main my output is 0 from all four pwm pins no matter the state of the PORTB.F0.
     
  13. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    Note that i have been able to run and stop the pwm by using the input PORTB.Fo as analog pin but in that case the ADC conversion interferes with the timing of the pwm and results in bad pwm signal.
     
  14. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    OK, a few problems here.
    In the 887A, you have to clear bit(s) in ANSELH for RB0, bit 4 (ANS12) must be 0 to allow reading from RB0 as a digital input. In chapter 3 of the databook, all the registers associated with all the ports are described. That's one reason your port input does not work.

    You can't put startPWM in a while loop, it just keeps restarting the PWM. If you look at the code snippet I posted above you'll see
    Code (Text):
    1.  
    2. while(1)  //run the next 4 statements forever..
    3. {
    4. while(PORTB.F0==1);  //the colon at the end of the line says to loop right there as long as the input is 1.  When it is, the next statement will be executed:
    5. startPWM(); // executed ONCE then wait on the port in the next line..
    6. while(PORTB.F0==0); // wait for the port to be 1 this time..
    7. stopPWM(); // then turn off the PWM - again ONCE
    8. } // while
    See the difference? For each IO change, startPWM/stopPWM only gets called once.

    Finally, you missed a double == in your port test. Your code assigns 1 to the still-analog input (!) then proceeds.

    Make sense?
     
    Last edited: Feb 23, 2015
  15. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    Thanks a lot JohnInTx. i followed you suggestion and wrote the following code.
    Code (Text):
    1. unsigned char sin_table[64]={0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 59, 64, 69, 74, 79, 84, 88, 93, 97, 100, 104, 107, 110, 113, 115, 118, 120, 121, 123, 124, 124, 125, 125, 125, 124, 124, 123, 121, 120, 118, 115, 113, 110, 107, 104, 100, 97, 93, 88, 84, 79, 74, 69, 64, 59, 53, 48, 42, 36, 30, 24, 18, 12, 6};   //100% duty cycle
    2.  
    3. unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
    4. unsigned int TBL_temp;
    5. unsigned char DUTY_CYCLE;
    6. unsigned int temp;
    7.  
    8. void interrupt(){
    9. if (TMR2IF_bit == 1){
    10. TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
    11. if (TBL_POINTER_NEW < TBL_POINTER_OLD){
    12. CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
    13.                                         }
    14. TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10;
    15. DUTY_CYCLE = TBL_POINTER_SHIFT;
    16. CCPR1L = sin_table[DUTY_CYCLE];
    17. TBL_POINTER_OLD = TBL_POINTER_NEW;
    18. TMR2IF_bit = 0;
    19.                 }
    20. }
    21. void Run_PWM(){
    22. PORTC.F2 = 0;
    23. PORTD.F5 = 0;
    24. PORTD.F6 = 0;
    25. PORTD.F7 = 0;
    26. SET_FREQ = 1024;
    27. TBL_POINTER_SHIFT = 0;
    28. TBL_POINTER_NEW = 0;
    29. TBL_POINTER_OLD = 0;
    30. DUTY_CYCLE = 0;
    31. PR2 = 0b01111100; //124
    32. CCP1CON = 0b01001100; // duty lowest bits + PWM mode
    33. TMR2IF_bit = 0;
    34. T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
    35. while (TMR2IF_bit == 0);
    36. TMR2IF_bit = 0;
    37. TRISC = 0;
    38. TMR2IE_bit = 1;
    39. GIE_bit = 1;
    40. PEIE_bit = 1;
    41. }
    42. void Stop_PWM(){
    43. PORTC = 0;
    44. PORTD = 0;
    45. }
    46.  
    47.  
    48. void main() {
    49. ANSEL = 0; //Disable ADC
    50. ANSELH = 0x00;
    51. CM1CON0 = 0; //Disable Comparator
    52. CM2CON0 = 0;
    53. TRISD.F0 = 1;
    54. TRISC.F2 = 0;
    55. TRISD.F5 = 0;
    56. TRISD.F6 = 0;
    57. TRISD.F7 = 0;
    58. TRISB.F0 = 0;
    59. PORTC.F2 = 0;
    60. PORTD.F5 = 0;
    61. PORTD.F6 = 0;
    62. PORTD.F7 = 0;
    63. PORTB.F0 = 0;
    64. PORTD.F0 = 0;
    65. SET_FREQ = 1024;
    66. TBL_POINTER_SHIFT = 0;
    67. TBL_POINTER_NEW = 0;
    68. TBL_POINTER_OLD = 0;
    69. DUTY_CYCLE = 0;
    70. PR2 = 0b01111100; //124
    71. CCP1CON = 0b01001100; // duty lowest bits + PWM mode
    72.  
    73. do{
    74. if (PORTD.F0==0){
    75.    PORTB.F0 = 0;
    76.    Stop_PWM();
    77.         }
    78. else {
    79.    Run_PWM();
    80.    PORTB.F0 = 1;
    81.   }
    82.  
    83. }while(1);
    84. }
    85.  
    now i have a different issue as described with simulation in the attached pdf file i am getting the wrong signals and at the wrong times.
    I want it to start with all 4 port as low then when PORTB.F0 is set high it should have wave form of 3 And when I set PORTB.F0 back to low all 4 pins should go low. I want the pwm to start from scratch whenever I set PORTB.F0 high.
     
  16. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    i meant portd.f0
     
  17. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    To stop the PWM, you need to disable it in CCP1CON then set the output ports to the desired OFF values. A running PWM will override the port values. Also, turn off the interrupts, stop the timer etc. A good way to know what to do to turn it off is to undo what you did to turn it on. Go through startPWM step by step and make sure you catch everything.

    Your do-while loop still calls startPWM or stopPWM each time through. You can't do that. Review what I wrote and what you have, go through the code line by line until you see how they are different.
     
  18. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    i changed the code
    Code (Text):
    1. unsigned char sin_table[64]={0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 59, 64, 69, 74, 79, 84, 88, 93, 97, 100, 104, 107, 110, 113, 115, 118, 120, 121, 123, 124, 124, 125, 125, 125, 124, 124, 123, 121, 120, 118, 115, 113, 110, 107, 104, 100, 97, 93, 88, 84, 79, 74, 69, 64, 59, 53, 48, 42, 36, 30, 24, 18, 12, 6};   //100% duty cycle
    2.  
    3. unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
    4. unsigned int TBL_temp;
    5. unsigned char DUTY_CYCLE;
    6. unsigned int temp;
    7. char i;
    8.  
    9. void interrupt(){
    10. if (TMR2IF_bit == 1){
    11. TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
    12. if (TBL_POINTER_NEW < TBL_POINTER_OLD){
    13. CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
    14.                                         }
    15. TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10;
    16. DUTY_CYCLE = TBL_POINTER_SHIFT;
    17. CCPR1L = sin_table[DUTY_CYCLE];
    18. TBL_POINTER_OLD = TBL_POINTER_NEW;
    19. TMR2IF_bit = 0;
    20.                 }
    21. }
    22. void Run_PWM(){
    23. PORTC.F2 = 0;
    24. PORTD.F5 = 0;
    25. PORTD.F6 = 0;
    26. PORTD.F7 = 0;
    27. SET_FREQ = 1024;
    28. TBL_POINTER_SHIFT = 0;
    29. TBL_POINTER_NEW = 0;
    30. TBL_POINTER_OLD = 0;
    31. DUTY_CYCLE = 0;
    32. //ECCPAS = 0b00000101; //autoshutodwm disabled
    33. PR2 = 0b01111100; //124
    34. CCP1CON = 0b01001100; // duty lowest bits + PWM mode
    35. TMR2IF_bit = 0;
    36. T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
    37. while (TMR2IF_bit == 0);
    38. TMR2IF_bit = 0;     // Timer2 interrupt flag
    39. TRISC = 0;
    40. TMR2IE_bit = 1;      //interrupt when TMR2 matches PR2
    41. GIE_bit = 1;      // Global interrupt enabled
    42. PEIE_bit = 1;     // peripheral interrupt enabled
    43. ECCPAS =0b11000000;       //autoshutodwm on INT pin high
    44. PWM1CON    = PWM1CON +   0b10000000  ;
    45. }
    46.  
    47. void main() {
    48. ANSEL = 0; //Disable ADC
    49. ANSELH = 0x00;
    50. CM1CON0 = 0; //Disable Comparator
    51. CM2CON0 = 0;
    52. TRISC.F2 = 0;
    53. TRISD.F5 = 0;
    54. TRISD.F6 = 0;
    55. TRISD.F7 = 0;
    56. TRISB.F0 = 1;
    57. PORTC.F2 = 0;
    58. PORTD.F5 = 0;
    59. PORTD.F6 = 0;
    60. PORTD.F7 = 0;
    61.   PORTB.F7 = 0;
    62.   Run_PWM();
    63.  
    64. while(1);
    65. }
    the pwm is interrupted with the enhanced pwm auto-shutdown ECCPAS. My new problem is that the code runs pwm at the beginning and stops after the second time i set the porb.f0 /INT pin low then runs again when i set it high. i want it to not run at the beginning when portb.f0 is initially low and start running after i set it high. your suggestions are more than welcome regarding this issue. thank you
     
  19. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Yeah.. the auto shutdown is not designed to be an on/off switch.

    If you want to try using the shutdown feature as a control, do the power up function manually then configure the PWM for auto shutdown. So..
    1)on power up with the PWM off, poll RB0 until its high.
    2)when RB0==1, go ahead and configure the PWM with auto shutdown on INT/ (RB0)
    3)the PWM should now follow RB0

    You should still have a stopPWM function in case you want to turn it off under software control. I confess I didn't know the 887 had an auto-shutdown feature. I probably would not use it as a control for the reason you experienced plus I'd probably use it as a safety device... but give it a try.

    Let us know how that works.
     
  20. Tamim Neak

    Thread Starter New Member

    Feb 23, 2015
    13
    0
    I have the following code now. i know it is not great but it does the job.
    Code (Text):
    1.  
    2. unsigned char sin_table[64]={0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 59, 64, 69, 74, 79, 84, 88, 93, 97, 100, 104, 107, 110, 113, 115, 118, 120, 121, 123, 124, 124, 125, 125, 125, 124, 124, 123, 121, 120, 118, 115, 113, 110, 107, 104, 100, 97, 93, 88, 84, 79, 74, 69, 64, 59, 53, 48, 42, 36, 30, 24, 18, 12, 6};  //100% duty cycle
    3.  
    4. unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
    5. unsigned int TBL_temp;
    6. unsigned char DUTY_CYCLE;
    7. unsigned int temp;
    8. char i;
    9.  
    10. void interrupt(){
    11. if (TMR2IF_bit == 1){
    12. TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
    13. if (TBL_POINTER_NEW < TBL_POINTER_OLD){
    14. CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
    15.   }
    16. TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10;
    17. DUTY_CYCLE = TBL_POINTER_SHIFT;
    18. CCPR1L = sin_table[DUTY_CYCLE];
    19. TBL_POINTER_OLD = TBL_POINTER_NEW;
    20. TMR2IF_bit = 0;
    21.   }
    22. }
    23. void Run_PWM(){
    24. PORTC.F2 = 0;
    25.  PORTD.F5 = 0;
    26.  PORTD.F6 = 0;
    27.  PORTD.F7 = 0;
    28.  SET_FREQ = 1024;
    29. TBL_POINTER_SHIFT = 0;
    30. TBL_POINTER_NEW = 0;
    31. TBL_POINTER_OLD = 0;
    32. DUTY_CYCLE = 0;
    33. ECCPAS =0b11000000;  //autoshutodwm on INT pin high
    34. //ECCPAS = 0b00000101; //autoshutodwm disabled
    35. PR2 = 0b01111100; //124
    36. CCP1CON = 0b01001100; // duty lowest bits + PWM mode
    37. TMR2IF_bit = 0;
    38. T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
    39. while (TMR2IF_bit == 0);
    40. TMR2IF_bit = 0;  // Timer2 interrupt flag
    41. TRISC = 0;
    42. TMR2IE_bit = 1;  //interrupt when TMR2 matches PR2
    43. GIE_bit = 1;  // Global interrupt enabled
    44. PEIE_bit = 1;  // peripheral interrupt enabled
    45. PWM1CON  = PWM1CON +  0b10000000  ;
    46. //ECCPAS &= 0x7f;
    47. }
    48. void Stop_PWM(){
    49. while( PORTB.F0 == 0);
    50. }
    51.  
    52. void main() {
    53. ANSEL = 0; //Disable ADC
    54. ANSELH = 0x00;
    55. CM1CON0 = 0; //Disable Comparator
    56. CM2CON0 = 0;
    57. TRISC.F2 = 0;
    58. TRISD.F5 = 0;
    59. TRISD.F6 = 0;
    60. TRISD.F7 = 0;
    61. TRISB.F0 = 1;
    62.  PORTC.F2 = 0;
    63.  PORTD.F5 = 0;
    64.  PORTD.F6 = 0;
    65.  PORTD.F7 = 0;
    66.   PORTB.F0 = 0;
    67.   Stop_PWM();
    68.   Run_PWM();
    69.  
    70. while(1);
    71.  }
    72.  
    Thanks a lot for your help. let me know if you have any suggestions to improve the code
     
Loading...