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

LX51 usage , hex 386 file format

Hi

We are using 8052 in our project. The project specifications are:

Keil PK51, Code banking with 2 code banks (using external 128K EPROM), 32K external SRAM, LX51 Linker, generating Intel 386 single hex output file, Code optimization level 9.

Program Size: data=94.4 xdata=32755 const=11396 code=79173
LX51 RUN COMPLETE.  0 WARNING(S),  0 ERROR(S)

This project was checked in 2 methods, and the related info generated in the .map file is as given below:

Method 1:
EA pin (pin 31) of microcontroller is connected to Vcc. So, the startup code in microcontroller contains small code, thro which the control jumps to the address location of main() in EPROM code bank 0. In this method, the project compiled without errors, but is not running. If we change to BL51 Linker, it generates 2 hex files. We programmed the EPROM, and the project running successfully.

LX51 LINKER/LOCATER:
C:\KEIL\C51\BIN\LX51.EXE COMMON {.\output\STARTUP.obj}, COMMON {.\output\L51_BANK.obj}, COMMON {.\output\mic40.obj}, BAN
>> K0 {.\output\Line40.obj}, BANK1 {.\output\print40.obj} TO .\output\416CV2 BANKAREA (0X003650, 0X00FFFF) REGFILE (.\ou
>> tput\416CV2.ORC) PRINT (.\listing\416CV2.map) IXREF CLASSES (CODE (C:0X2000-C:0XFFFF), XDATA (X:0X0000-X:0XFFFF)) SEG
>> MENTS (?PR?ONTIMERISR?MIC40 (C:0X2000), ?PR?ONSERIALPORTISR?MIC40 (C:0X2500), ?PR?MAIN?LINE40 (B0:0XFFF0), ?CO?LINE40
>>  (B0:0X8000), ?CO?PRINT40 (B1:0X8000))

Method 2:
EA pin (pin 31) of microcontroller is connected to Ground. So, there is no code in microcontroller, and the code will start from 0x0000 location in EPROM. In this method, the project is running absolutely fine.

LX51 LINKER/LOCATER:
C:\KEIL\C51\BIN\LX51.EXE COMMON {.\output\STARTUP.obj}, COMMON {.\output\L51_BANK.obj}, COMMON {.\output\mic40.obj}, BAN
>> K0 {.\output\Line40.obj}, BANK1 {.\output\print40.obj} TO .\output\416CV2 BANKAREA (0X001650, 0X00FFFF) REGFILE (.\ou
>> tput\416CV2.ORC) PRINT (.\listing\416CV2.map) IXREF SEGMENTS (?PR?ONTIMERISR?MIC40 (C:0X0100), ?PR?ONSERIALPORTISR?MI
>> C40 (C:0X0300), ?PR?MAIN?LINE40 (B0:0XFFF0), ?CO?LINE40 (B0:0X8000), ?PR?LINEMAIN?LINE40 (B0:0XFFF0), ?CO?PRINT40 (B1
>> :0X8000))


Q. If the EA pin (pin 31) of microcontroller is connected to Vcc, kindly suggest a solution to the project Method 1 using LX51 Linker.

  • So, the startup code in microcontroller contains small code, thro which the control jumps to the address location of main() in EPROM code bank 0.

    What is this 'small code'? It should be the appropriate extract of the .hex file from the LX51. if it is not, then you cannot just 'jump to main()'.

    It seems you need to check and understand the mapping of the hardware. Especially as you said that method 2 with LX51 works.

  • In Method 1, the microcontroller code is:

    void main(void)
    {
            EA = 0;
            ((void (code *)(void))0xFFF0)(); //It is the location if main() in code bank 0
    }
    

    Using BL51 Linker, we are using the same code in microcontroller.