Embedded project

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pratish
    New Member
    • Jan 2007
    • 4

    Embedded project

    hey frnds, i m doing my project on RFID (Radio Frequency Identification) using AT89c51 microcontroller . My problem is that i want to take input from Port3 n want to send output on same port but on some different pin...
    So I want to know dat can we configure particular pin of da port...

    for e.g.
    P3.2=1;
    P3.5=0;

    Is this possible ...
    Thnax
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    First, if you have better grammer and spelling skills you should use them. Your question will get more attention and responses if it is well formatted and people dont have to read stuff like "dat" and "da".

    That being said here is some information taken from the product documents:

    Port 3 is an 8-bit bi-directional I/O port with internal pullups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current because of the pullups. Also, Port 3 also serves the functions of various special features of your microcontroller , specifically P3.5 is an external timer input. You may want to consider using a different port that is not serving the special features of your chip. Port 1 is 8-bit and bi-directional and can also source four TTL inputs, but it has an added bonus as not serving the features that are inherent in the microcontroller . If I am looking at the correct documentation of your microcontroller , it looks like you can pull all the pins high and use them for input, store the bits you want to in the buffer, then pull the pins low again to output the bits in the buffer. But it would require a change in the directionality of all the pins, from input to output (or vice versa).

    Comment

    • Motoma
      Recognized Expert Specialist
      • Jan 2007
      • 3236

      #3
      You may be able to just perform a logical AND operation with the Port and an Integer with the correct bit set.

      Comment

      • pratish
        New Member
        • Jan 2007
        • 4

        #4
        Thanks for replying my query and also sorry for using improper language.
        Now, i tell you in more detail.
        Now.... i am giving you pin description for my project..
        PORT1-------
        P1.0 and P1.1 ------LEDs are connected.

        PORT2-----
        P2.0 -------- one buzzer is connected.

        PORT3--------
        P3.0-----RXD
        P3.1-----TXD
        P3.2-----RFID Tag 1


        LOGIC
        ----------

        When RFID Tag1 i.e P3.2 gets signal, it will send signal to P3.1through which the output is been given to computer.
        IF RFID Tag1 i.e.P3.2 doesnt get signal then glow the LED which is connected to P1.0 and ring the buzzer which is connected to P2.0.


        --------------------

        This is my basic testing code.
        If i am able to do this, i will proceed further with some complicated things......
        So please help me out friends.

        Comment

        • Motoma
          Recognized Expert Specialist
          • Jan 2007
          • 3236

          #5
          Originally posted by pratish
          PORT1-------
          P1.0 and P1.1 ------LEDs are connected.

          PORT2-----
          P2.0 -------- one buzzer is connected.

          PORT3--------
          P3.0-----RXD
          P3.1-----TXD
          P3.2-----RFID Tag 1

          LOGIC
          ----------

          When RFID Tag1 i.e P3.2 gets signal, it will send signal to P3.1through which the output is been given to computer.
          IF RFID Tag1 i.e.P3.2 doesnt get signal then glow the LED which is connected to P1.0 and ring the buzzer which is connected to P2.0.

          --------------------
          This seems to be a little different than your original question.
          If I understand your system correctly, pseudocode for your program will look a little like this:

          Code:
          while(1)
          {
            if(recieved() == 1) {
              //unset LEDs
              PORT1 = PORT1 & 0x3F; // 00111111
              //do signal processing
              dorecieved();
            } else {
              //set LEDs
              PORT1 = PORT1 | 0xB0; // 11000000
              dobuzzer();
            }
          }
          
          int recieved()
          {
            return PORT3.2;
          }
          
          void dobuzzer()
          {
            (pulse width modulation for loop)
            {
              if(up == 1)PORT2 = PORT2 | 0x80; // 10000000
              else PORT2 = PORT2 & 0x7F; // 01111111
            }
          }
          Maybe I'm just way off.

          Comment

          • horace1
            Recognized Expert Top Contributor
            • Nov 2006
            • 1510

            #6
            Originally posted by pratish
            hey frnds, i m doing my project on RFID (Radio Frequency Identification) using AT89c51 microcontroller . My problem is that i want to take input from Port3 n want to send output on same port but on some different pin...
            So I want to know dat can we configure particular pin of da port...

            for e.g.
            P3.2=1;
            P3.5=0;

            Is this possible ...
            Thnax
            try
            Code:
            P3_2 = 0;
            P3_2 = 1;

            Comment

            • pratish
              New Member
              • Jan 2007
              • 4

              #7
              thanks friends...
              I m also having problem wid serial communication.. .
              I dont know how to use UART...
              Please help me ..

              Comment

              • Motoma
                Recognized Expert Specialist
                • Jan 2007
                • 3236

                #8
                Originally posted by pratish
                thanks friends...
                I m also having problem wid serial communication.. .
                I dont know how to use UART...
                Please help me ..
                You are going to have to give a little more information if you want our help then.

                Comment

                • horace1
                  Recognized Expert Top Contributor
                  • Nov 2006
                  • 1510

                  #9
                  Originally posted by pratish
                  thanks friends...
                  I m also having problem wid serial communication.. .
                  I dont know how to use UART...
                  Please help me ..
                  try this
                  Code:
                  //*************************************************************************
                  // Using 16Mhz clock
                  // Timer 2 is used and therfore the Reload value needs to be caluclated
                  // i.e
                  // reload value for RCAP2H and RCAP2L = 65536 - (osc freq/32* BaudRate)
                  // 65536 - (16Mhz/16*9600)  in X2 mode (/2)
                  // 65536 - 104
                  // 65432 or FF98 in hex
                  // therefore 	RCAP2L = 0x98
                  //				RCAP2H = 0xff
                  // This gives 9600b/s
                  //*************************************************************************
                  
                  void serial_init()
                  {
                  	T2CON 	= 0x30;			// use timer 2 to rx & rx serial clock		
                  	RCAP2L 	= 0x98;			// Reload value for Hi/Lo byte of T2 
                  	RCAP2H 	= 0xff;
                  	TL2 = 0x98;				// Set the same reload value for the first clock
                  	TH2 = 0xff;
                  
                  	SCON = 0x50;			// 8bit Uart + Enable Reception on Rx
                  	TR2 = 1;				// enable Timer 2
                  	TI 	= 1;				// enable Transmission
                  	CKCON |= 0x11;			// Divide clock by 2
                  
                  }
                  
                  void hexout(unsigned char v)
                  {
                  	hex(v>>4);
                  	hex(v);
                  }
                  
                  void hex(unsigned char v)
                  {
                  	v &= 0x0f;
                  	if (v > 9) putchar(v + '7');
                  	else putchar(v + '0');
                  }
                  once initialised you should be able to use putchar() and printf("hello\n ")

                  Comment

                  • pratish
                    New Member
                    • Jan 2007
                    • 4

                    #10
                    Thanks Friends...
                    Now my Circuit is working very fine..
                    Now the problem is, i dont know how to do serial communication.
                    More precisely....

                    Let me give you pin description
                    In My project i have.
                    P3.0/RXD ----------RXD
                    P3.1/TXD ----------TXD
                    P3.2/INT0 --------RFID TAG 1
                    P3.3/INT1 ---------RFID TAG 2
                    My project is RFID in which i have two RFID transmitters.(T ag 1 and Tag 2).
                    So when RFID TAG1 is in range,P3.2 gets signal, and it should show the message on the hyperterminal that"Tag1 is in range"..Same for "Not in range".

                    So My problem is that i dont know how to do serial communication .
                    I have used MAX232 for the same.

                    .....
                    I have done the serial communication with AT90s8535...In which i have used UART.
                    I know that for enabling TXD and RXD, we have to use UCR
                    For setting baud rate , we have to use UBRR
                    For input output , we have to use UDR...
                    These are the registers used for serail communication .....
                    But I dont know how to use same in AT89C51.
                    Please help me out.....

                    Comment

                    Working...