8051: square or power function?

Help
Rabis49
2010-05-01
2013-03-12
  • Rabis49
    Rabis49
    2010-05-01

    Hi,
    #define x2      1
    #define baud 19200
    #define xtal    22118400

    #if (x2 == 1)
      CLKREG = 0x01;
    #else
    CLKREG = 0x00;
    #endif

    Okay.
    Now I need the power function  ( … 2^x2 … 2**x2 …. potenz(2;x2) ….. ????)

    Is there a way  to solve this problem for the following calculation?

    BRL = 256-(xtal/baud/192) * 2^x2 ; <- thats wrong

    (It's for a AT89S8253)
    Thanks for ideas, help & answers

    Rabis49

     
  • Maarten Brock
    Maarten Brock
    2010-05-02

    There is no power of operator in C. There is a pow function but that won't help here.
    But I guess x2 can have only two values so I'm sure you can think of a different formula.

     
  • Rabis49
    Rabis49
    2010-05-04

    Thanks for the answer, Maarten.
    Yes, this example is simple.
    Okay, I can write the function twice.
    But a pow equivalent could be a fine function ;-)