embeded/80512009. 4. 14. 10:57
대용량의 데이터(예를들어 폰트데이터)를 저장하는데 있어 기본변수로 선언을 했더니 문제가 발생했다.
Memory Model은 기본 값인 Small model이었고, 이로 인해서 data형으로 선언이 된다.(위의 small model 참조)

그래서 Large model로 변경하니 xdata로 되었고, 이로 인해 64k까지 가능해져서 에러없이 돌아 갔지만,
다른 문제가 발생을 해서 오작동을 한것으로 생각이 된다.

아무튼 플래시는 넉넉하니, code라는 변수 타입을 선언하면 rom에 저장이 되고,
메모리에 저장이 되지 않으므로 별다른 문제 없이 프로그램이 실행된다.


Memory TypeDescription
code Program memory (64 KBytes); accessed by opcode MOVC @A+DPTR.
data Directly addressable internal data memory; fastest access to variables (128 bytes).
idata Indirectly addressable internal data memory; accessed across the full internal address space (256 bytes).
bdata Bit-addressable internal data memory; supports mixed bit and byte access (16 bytes).
xdata External data memory (64 KBytes); accessed by opcode MOVX @DPTR.
far Extended RAM and ROM memory spaces (up to 16MB); accessed by user defined routines or specific chip extensions (Philips 80C51MX, Dallas 390).
pdata Paged (256 bytes) external data memory; accessed by opcode MOVX @Rn.

If no memory type is specified for a variable, the compiler implicitly locates the variable in the default memory space determined by the memory model: SMALL, COMPACT, or LARGE. Function arguments and automatic variables that cannot be located in registers are also stored in the default memory area. Refer to Memory Models for more information.

[출처 : http://www.keil.com/support/man/docs/c51/c51_le_memtypes.htm]


xdata

The xdata memory type may be used to declare variables only. You may not declare xdata functions. This memory is indirectly accessed using 16-bit addresses and is the external data RAM of the 8051. The amount of xdata is limited in size (to 64K or less).

Variables declared xdata are located in the XDATA memory class.
Declare xdata variables as follows:
unsigned char xdata variable;
[출처 : http://www.keil.com/support/man/docs/c51/c51_le_xdata.htm]

code

The code memory type may be used for constants and functions. This memory is accessed using 16-bit addresses and may be on-chip or external.

    * For constants (ROM variables), code memory is limited to 64K.
      Objects are limited to 64K and may not cross a 64K boundary.
      Constant variables declared code are located in the CODE memory class.
    * For program code (functions), code memory is limited to 64K.
      Program functions are stored in the CODE memory class by default.
      The code memory type specifier is not required.

Declare code objects as follows:
unsigned char code code_constant;
unsigned int func (void)
{
    return (0);
}
[출처 : http://www.keil.com/support/man/docs/c51/c51_le_code.htm]

Small Model

In this model, all variables, by default, reside in the internal data memory of the 8051 system as if they were declared explicitly using the data memory type specifier.

In this memory model, variable access is very efficient. However, all objects (that are not explicitly located in another memory area) and the stack must fit into the internal RAM. Stack size is critical because the stack space used depends on the nesting depth of the various functions.

Typically, if the linker is configured to overlay variables in the internal data memory, the small memory model is the best model to use.

[출처 : http://www.keil.com/support/man/docs/c51/c51_le_modelsmall.htm]

Large Model

In the large model, all variables, by default, reside in external data memory (which may be up to 64K Bytes). This is the same as if they were explicitly declared using the xdata memory type specifier.

The data pointer (DPTR) is used to address external memory. It is important to note that memory access through the data pointer is inefficient and slow, especially on variables that are two or more bytes long. This type of data access mechanism generates more code than the small model or compact model.

[출처 : http://www.keil.com/support/man/docs/c51/c51_le_modellarge.htm]

Posted by 구차니