8051 programming help

Discussion in 'Embedded Systems and Microcontrollers' started by tharunmalli, Apr 17, 2014.

  1. tharunmalli

    Thread Starter New Member

    Apr 7, 2014
    12
    0
    I need to write a c program to receive a character from hyperterminal . If the entered character is y then P0^1 should go high and if i press n then P0^0 should go low, if i press any other character it should retain its previous state..
    please help me..
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,429
    3,360
    Then start writing and show us your code.
     
  3. AfdhalAtiffTan

    Active Member

    Nov 20, 2010
    117
    11
    You could start by using "mikroC PRO for 8051" compiler.
    It has library for the UART module.
     
  4. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    496
  5. tharunmalli

    Thread Starter New Member

    Apr 7, 2014
    12
    0
    I compiled the below program . It is showing error near P0^0=1 .. Please find the mistake and post the correct code. Please help
    #include<reg51.h>
    unsigned char mybit;
    void main(void)
    {
    TMOD=0x20;
    TH1=0xFD;
    SCON=0x50;
    TR1=1;
    while(1)
    {
    while(RI==0);
    mybit=SBUF;
    if(mybit=='y')
    P0^0=1;
    if(mybit=='n')
    P0^1=0;
    RI=0;
    }
    }
     
  6. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    Maybe the usage of P0^0 is wrong.

    Try this:
    After the include statement, define P0.0 and P0.1 as follows:
    sbit P00 = P0^0;
    sbit P01 = P0^1;

    To set P0.0 to 0; use P00=0;
     
Loading...