RS232 interface, DE2-70 board

This is a discussion on RS232 interface, DE2-70 board within the C Programming forums, part of the General Programming Boards category; Can someone please help me? I have two weeks left in my senior design project and have to interface a ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    2

    Exclamation RS232 interface, DE2-70 board

    Can someone please help me? I have two weeks left in my senior design project and have to interface a Doran 2200 Scale to an Altera DE2-70 board using RS232. I have the configuration set-up on the board and have the scale transmitting data to the board (I know this based off the blinking LED that is telling me data is being received). I am using C code to run on a softcore processor that I have put in the FPGA and need to read data from the RS232 port. I have this code written so far;

    Insert
    Code:
    void get_weight_from_uart(char * weight)
    {
            FILE* fp;
            char in_char = 0;
            int pointer = 0;
           
            fp = fopen ("/dev/RS232", "r+");        //Open file for reading and writing
            if (fp ==0)
            {
                printf("error");
            }
            if (fp)
            {
                    while (1)
                    {
                            in_char = fgetc(fp); // Get a character from the UART.
                           // if ((in_char == '\n') | (in_char == '\r') | (in_char == 0))
                           // {
                            //        fclose (fp);
                           //         return;
                          //  }
                           // else
                           // {
                                    weight[pointer++] = in_char;
                                    printf("0%0x\n",weight);
                                    delay(1000);
                           // }
                    }
                    fclose (fp);
            }
         //   return 0;
    }
    However when I read the data from those ports, I get the same thing printing over and over again which is;

    05ffffa8

    I am not sure whether or not I have the correct code written or why I am getting the same thing. Please advise.

    Thanks.
    Duffbuster

  2. #2
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,049
    The data read from the port maybe different each time but the code prints the location of weight over and over again, as in
    Code:
    printf("0%0x\n", weight);

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    2
    Thanks for the quick response this is going to sound stupid because I am not very good with C but how do I print the values in weight?

  4. #4
    Registered User
    Join Date
    Oct 2008
    Location
    TX
    Posts
    2,049
    Code:
    printf("0%0x\n", weight[pointer-1]);
    Last edited by itCbitC; 05-02-2009 at 02:24 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function trouble
    By rebel in forum C++ Programming
    Replies: 4
    Last Post: 12-21-2005, 05:23 AM
  2. Pick a number....
    By Salem in forum A Brief History of Cprogramming.com
    Replies: 39
    Last Post: 01-19-2003, 07:27 AM
  3. Isn't the C Board a cool name?
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 12-23-2002, 01:09 PM
  4. Considering shutting down the General Discussions board
    By webmaster in forum A Brief History of Cprogramming.com
    Replies: 59
    Last Post: 09-26-2002, 09:41 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21