Thread: Serial port receive Buffer help

  1. #1
    Registered User Daffodils's Avatar
    Join Date
    Jul 2009

    Unhappy Serial port receive Buffer help

    This is My First post to this Forum....

    suggest me which is the best way to receive string from serial port by using own functions with out using standard library.....

    Fixed Char array or by using pointers??

    Please Help me to receive strings from serial port of a microcontroller using C..

    I Established the communication with controller and the function getchar() can receive one charector at a time from serial port succesfully..

    /* SERIAL.C                                        */
    #include <controllerxx.H>            
    #define NULL     '/0'
    /* implementation of getchar */
    int getchar (void)  {                     /* Read character from Serial Port   */
      while (!(U1LSR & 0x01));	   //Don't care about this this is controller registors 
      return (U1RBR);
    //Here 	is my code start....	getchar() function can read one charector at time  from serial port
    All I need to do is store this to a variable and whenever iam calling from main function it should display the string...
    //Function  defenitions
    unsigned char string_receive(void)
    static char uart_data[200];
    static char count=0;
    return uart_data[200];	 
    int main (void)
     char abc[200];
     init_serial ();              /* Initialized Serial Interface   ..its OK I can receive Char..    */
    Last edited by Daffodils; 07-23-2009 at 06:18 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    First practice passing and returning arrays (or more accurately, pointers).

    > #define NULL '/0'
    1. NULL (the pointer) is not the same thing as nul (the zero character).
    2. It should be written as '\0' anyway.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. serial port to poll on request
    By infineonintern in forum C++ Programming
    Replies: 2
    Last Post: 06-11-2009, 06:52 AM
  2. Serial Port - Receive Packet
    By samuelmoneill in forum C Programming
    Replies: 21
    Last Post: 04-22-2009, 02:07 AM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Send and receive through serial Port
    By overspray in forum C++ Programming
    Replies: 1
    Last Post: 07-21-2004, 04:15 PM
  5. DOS, Serial, and Touch Screen
    By jon_nc17 in forum A Brief History of
    Replies: 0
    Last Post: 01-08-2003, 04:59 PM

Tags for this Thread