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
  • "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;
    

Reply
  • "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;
    

Children
No data