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

New to C51

Hi,

I'm just switching over from Atmel AVR's to work on a project that involves working with AT89C51SND1 micro. Perviously, I've used Atmel's CodeVision Compiler and now switching over to Keil.

I have very few basic questions that I need help with, regarding the comipler. As I understand that to declare a port as an input in Kiel, the format is:

P1 = 0xff; // (Entire Port 1 is Input)

what i'd like to know is if i want to read a pin value on P1, how do i do it? is it...

some_variable = P1;

because in CodeVision it is as following:

some_variable = PINA;

and similarly how to write to a port, is it:

P1 = value;

in Codevision it is:

PORTA = value;

I've downladed some exmaple programs of the keil website and they've been helpful, but just want to confirm if i'm on the right track. Thank you

Parents
  • Hi

    The 51 ports are quisi-bidirectional.

    To read X=P1
    to write P1=X

    Normally you would write onse to the port to make them highs ( that is the P1 =0xFF)

    Note that if the port is driving a load it may not read back what you wrote. The load may affect the pin voltage. This is since the read is from the Port not the latch.

Reply
  • Hi

    The 51 ports are quisi-bidirectional.

    To read X=P1
    to write P1=X

    Normally you would write onse to the port to make them highs ( that is the P1 =0xFF)

    Note that if the port is driving a load it may not read back what you wrote. The load may affect the pin voltage. This is since the read is from the Port not the latch.

Children