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

how to send an array to microcontroller through serial communication

Hi all
iam working on c51 cygnal microcntrollers
iam performing serial communication ,
at the console iam performing some manipulations and iam updating in an
array[255] now i would like to send this array to controller and iwant to write the received array to external memory of microcntroller could you please
suggest me how perform this ,
note i have already established serial
communication between console and microcontroller, at the console iam running c programme from that programme i have to send one array to microcontroller.please suggest me how to do this.

regards
ken

  • "note i have already established serial communication between console and microcontroller"

    What does that mean?

    Do you mean that you can now send something from your PC to the micro controller?
    So what is your specific problem now?

    Sending an array is simply a matter of sending each element in turn, isn't it?

    Similarly for receiving it.

  • Hi
    neil thanks for your reply. well actually at the receiving end ie microcontroller how to receive this array in microcontroller.
    actually my project involves the following

    1) at console iam performing some overhead calculations and also i will take data from user, at last iam sending through serial port
    assume
    sarray[]={01,1e,30,30,12,32,21,31,38,84,18,32,47,12,3487,12,34,80}
    actually this type of array is generated at console using c programme .and at last iam writing the each element of array to serial
    port ,
    ie for(i=0;i<len;i++)
    {
    ch=sarray[i];
    outportb(port1,ch);
    }
    at microcontroller end its waiting to receive this array how to receive this array
    can i directly initialise an array in the micrcontroler will it store these datas

    regards
    narasimhajb

  • Think about it:
    When you send an array, you take each element in turn & transmit it.

    Receiving is purely the converse - you receive each element in turn.

  • hi
    neil
    do you have any documents regarding this ?


    regards
    ken

  • There are several serial comms examples on this very site.

  • Note that you can set up the simulator so that it uses the PC's serial port for the simulated UART.

    Thus you can load your code into the simulator and connect the simulator's COM: port to the COM: port that your PC software is using, and debug the whole thing without needing any target hardware at all!

    You might find this easier than downloading to the real target?

  • Please read the instructions on the 'Reply' form - they tell you how to post code.

    for(i=0;i<len;i++)
    {
       ch=sarray[i];
       outportb(port1,ch);
    }
    Note that you may need to wait for the PC to finish transmitting each character before sending the next (if your PC has FIFOs enabled, you need to check instead that the FIFO is not full).

  • Does the PC run a terminal emulation program, e.g. Hyperterminal? When the user types a character in the Hyperterminal window, the character does not go out the DB9 comm connector on the back of the PC, but goes into the debugger's SBUF instead?

  • If you use the interrupt example in Schultz' 'C and the 8051', beware. It is good enough to get you started but you will need to fix the accesses to TI and/or RI and fix the test(s) for buffer full or empty.

  • "When the user types a character in the Hyperterminal window, the character does not go out the DB9 comm connector on the back of the PC, but goes into the debugger's SBUF instead?"

    No.

    If the user types a character in the Hyperterminal window, it does go out of the DB9 comm connector on the back of the PC - you need to connect that COM: port to the COM: port that the uVision simulator is using (you will need a crossover cable).
    The two COM: ports could be on the same computer, or different computers.