This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

i would like to know the c++ code to generate increasing pwm

i would like to know the c++ code to generate 1 increasing pwm on one pin of 89c2051 when signal comes at 3.4 of 89c2051 and decreasing pwm on the same pin of 89c2051 when signal comes at 3.5 [in of 89c2051.

Parents Reply Children
  • "... just look out for the number of colon ..."

    Yes, I noticed that just after I did the post.

    No problem, I've already updated the compiler to allow any number of them and act as the programmer intended.

    It now has the same action for the problematic "=" and "==". So long as you enable the -AsProgrammerIntends switch it will do what you want.

    I'm also considering the -ChangeAllMagicNumbers switch to enable translation of nasty magic numbers to readable constants.

  • "I'm also considering the -ChangeAllMagicNumbers switch to enable translation of nasty magic numbers to readable constants."

    What we always have wanted.

    enum {
        ONE = 1,
        TWELVE = 12
    };
    
    enum {
        UNSIGNED_ONE_SHIFTED_LEFT_12_STEPS = (unsigned)ONE << TWELVE
    };
    
    enum {
        MAGIC_BIT_TO_TURN_ON_POWER_TO_ADC0 = UNSIGNED_ONE_SHIFTED_LEFT_12_STEPS
    };
    
    A |= MAGIC_BIT_TO_TURN_ON_POWER_TO_ADC0;