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

Simulator issue with printf?

While using the simulator, the values of i in the serial window are shifted by left 8 bits.

#include "stdlib.h"
#include "stdio.h"
#include "reg51.h"

void main (void)
{
    unsigned char i;
    SCON  = 0x50;
    TMOD |= 0x20;
    TH1   = 221;
    TR1   = 1;
    TI    = 1;

    for (i = 0; i < 8; i++)
    {
        printf("%x\n", i);
    }
}

Parents
  • Check in other threads.

    Reasonable questions are always answered with reasonable answers.

    However, people comming with unreasonable requests - or as in this case ordering us to supply turn-key solutions to school work - will have to settle for answers about methodology.

    No, I do not *feel* smart about myself, talking about encoding or decoding BCD numbers just as I'm not *feeling* smart about being able tie my shoe laces either.

    I know that the net is full of trolls and intentionally irritating people. However, I have no good means to separate trolls from people actually wanting help. As long as a thread doesn't diverge into a constant series of invectives, I always try to suggest a suitable next step for solving a problem. If it's a troll, then the step isn't needed. If it's a fool, the step may be ignored. Now and then, the suggesition may be picked up and acted upton.

    In the end, I don't care too much if a suggestion is acted upon or not. People who want advice will get it. People who want to ignore advice are free to ignore them. That is life.

Reply
  • Check in other threads.

    Reasonable questions are always answered with reasonable answers.

    However, people comming with unreasonable requests - or as in this case ordering us to supply turn-key solutions to school work - will have to settle for answers about methodology.

    No, I do not *feel* smart about myself, talking about encoding or decoding BCD numbers just as I'm not *feeling* smart about being able tie my shoe laces either.

    I know that the net is full of trolls and intentionally irritating people. However, I have no good means to separate trolls from people actually wanting help. As long as a thread doesn't diverge into a constant series of invectives, I always try to suggest a suitable next step for solving a problem. If it's a troll, then the step isn't needed. If it's a fool, the step may be ignored. Now and then, the suggesition may be picked up and acted upton.

    In the end, I don't care too much if a suggestion is acted upon or not. People who want advice will get it. People who want to ignore advice are free to ignore them. That is life.

Children