AT89C51RC2 FLIP Programming Guide - ECEE

42 downloads 318 Views 145KB Size Report
/PSEN must be released after the falling edge of the reset signal, since /PSEN is normally an output that is driven by the processor. /EA = 1 and /PSEN = 0 at the ...
AT89C51RC2 FLIP Programming Guide In order to program the AT89C51RC2 using FLIP, the processor needs to execute the on-chip bootloader code. The bootloader can be activated by two methods (hardware conditions or regular boot process), as explained on page 93 of the AT89C51RC2 data sheet and in the Atmel application note "C51 General Information about Bootloader and in System Programming". In order to execute the bootloader using hardware conditions, the /EA pin must be high and the /PSEN pin must be low at the falling edge of the reset signal. /PSEN must be released after the falling edge of the reset signal, since /PSEN is normally an output that is driven by the processor. /EA = 1 and /PSEN = 0 at the falling edge of reset One could accomplish these hardware conditions by the following: 1. 2. 3. 4. 5. 6.

Configure /EA to be a logic high, perhaps by using a jumper. Press and hold the reset pushbutton. Press and hold a pushbutton that connects /PSEN to ground through a 1K resistor. Release the reset pushbutton (while still holding the /PSEN pushbutton). Release the /PSEN pushbutton. The processor should now be in bootloader mode. Configure /EA as necessary for the user application (either high or low). To execute user code that is stored in the on-chip flash, /EA will remain high.

This configuration will forcibly place the AT89C51RC2 in serial programming mode. After reset, the Flip software can be started or set up for RS-232 communication and will connect to the bootloader in the processor. Hardware changes required: (Refer to jumper configuration of AT89C51RC2) 1. Connect a three-pin header and jumper to allow the /EA pin to be configured as high or low. 2. Connect a pushbutton switch or three-pin header and jumper to allow the /PSEN pin to be configured as low or to allow it to toggle as an output pin under normal operation. Use a 1K current limiting resistor.

1

Programming Using Flip The AT89C51RC2 can be programmed via the RS-232 serial interface using the Atmel FLIP software. Flip can be freely downloaded from: http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3886 Step 1: Start FLIP. Note that extensive help is available from within FLIP. Step 2: Select device AT89C51RD2 for the Atmel AT89C51RC2 controller. The Atmel AT89C51RC2 controller is not listed in the Flip device selection list. See the figure below.

Step 3: Click communication icon or (settings -> Communication) and select RS-232 for setup. Select appropriate baud rate and comport for hardware and then press Connect. (Highest baud rate supported is 57600). If the AT89C51RC2 is in programming mode (executing the bootloader), then it will enable the programming options; otherwise, it will give a time out error. Make sure that the device is properly configured in serial programming mode by making /EA = 1 and /PSEN = 0 when the processor comes out of reset.

2

Step 4: Load hex file. On loading, the hex file name will be displayed in the center under flash buffer information along with size of it. Then, perform Erase, Blank Check, Program and Verify cycles. Note: Blank check may fail at address 0xF800 since it is reserved for the boot ROM and erasing flash will set the default value for HSB and BSB. (For more information about the HSB (Hardware Security Byte), read AT89C51RC2 datasheet page 87). You can ignore this error due to blank check. Step 5: After successful programming, the user application can be tested by pressing the red “Start Application” button. This will place the device in normal mode and then the user program will run normally. (Do not tie /PSEN low during execution, even if it is executing from internal memory. Configure /PSEN as either floating or output pin before pressing “Start Application”).

3

Jumper Configuration for AT89C51RC2: The AT89C51RC2 can be programmed serially through RS-232 port without physically removing it from circuit. In order to program AT89C51RC2 chip, it is required to switch its mode to programming mode. The AT89C51RC2 samples the status of the /PSEN and /EA pin on falling edge of reset and if /EA and /PSEN are tied to VCC and GND respectively on power on reset then it places chip in the programming mode. /PSEN and /EA pins can be configured using pushbuttons or a set of jumpers. The following diagram shows the jumper settings: A) C501 MODE OF OPERATION: Both the jumpers are in position 1 (/EA = 0) (Note: /EA can be tied to high to fetch from internal program memory) 39 38 37 36 35 34 33 32 1 2 3 4 5 6 7 8 19 18 31 9

U1 P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7

P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15

P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 XTAL1 XTAL2

P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD ALE/PROG PSEN

21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17

1

7408

2

To EPROM

3

Jumper 1 OR Switch 1

30 29

1K

2

EA/VPP RST

Pulldown resistor Jumper 2

AT89C51

1 VCC_BAR

2

B) FLIP PROGRAMMING MODE: Both the jumpers are in position 2 at falling edge of reset. /PSEN is then released after reset, so that it can operate normally. Use 1K current limiting resistor for /PSEN pull-down. U1 39 38 37 36 35 34 33 32 1 2 3 4 5 6 7 8 19 18 31 9

P0.0/AD0 P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 XTAL1 XTAL2 EA/VPP RST

P2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD ALE/PROG PSEN

21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17

1 2

7408

1

30 29

2

Pulldown resistor

Jumper 1 OR Switch

AT89C51

1K

1 2 Jumper 2

4

VCC_BAR

3

To EPROM