Code to microcontroller

Discussion in 'Embedded Systems and Microcontrollers' started by rocky3015, Nov 24, 2009.

  1. rocky3015

    Thread Starter New Member

    Nov 24, 2009
    2
    0
    Hi guys! i am new here, this being my first thread. i have a basic doubt. once i have written a program for the 8051 microcontroller, how does this code go to the program memory of the 8051? i mean the code has to go to the microcontroller through one of the I/O ports (out of the 4 existing I/O ports), then how does it go to the program memory and not to the data memory? how does the microcontroller know whether it is a program code or normal data? answer to this question would help me in making my project. waiting for your replies. thanks.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    The answers that you seek are in the datasheet. There are a variety of methods, but my favorite is to use the onboard UART to load code into the program memory.

    In executing instructions there is a control signal called PSEN*. This stands for Program Store Enable, and it is active low. It is normally connected to the OE* input of an external EPROM/FLASH memory chip. When data is read or written to data memory another pair of control signals is active called RD* and WR*

    Lastly there is a control signal called ALE, which stands for Address Latch Enable, which is used to demultiplex the low order address/data bus.
     
  3. rocky3015

    Thread Starter New Member

    Nov 24, 2009
    2
    0
    Hi Bravo, your reply did indeed help. Thanks. What you mentioned holds true when the code is being written to external memory, but what if the code is to be written to internal, on-chip memory. This is still not clear. Say for JTAG interface, do the instructions (code) also go in the microcontroller via one of the ports (might be serial)? If yes, then how do these ports get connected to the program memory instead of data memory, for loading the code to the microcontroller? I mean, does some pin of the microcontroller get a select signal to select program memory?
     
  4. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    You can download the code into the program code space of the 8051 using the JTAG interface that comes with some 8051 (http://www.silabs.com).

    For some 8051s (such as the Atmel AT89C5131), you can download the codes through the USB port on the chip.
     
  5. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    I was refering to the internal program memory. In the Atmel AT89C51CC01 there is a UART bootloader that allows a program called FLIP, a free download from the Atmel website, to download and program the INTERNAL program memory. In the DATASHEET is the description of how this works.

    As for the pins, they are P3.0 and P3.1 which are the TxD and RxD pins for the onboard UART controlled by registers SCON and SBUF.
     
Loading...