embeded/Cortex-M3 Ti2012. 6. 30. 11:17
말이 거창한데...
아무튼 스택의 크기가 작으면 함수 호출의 깊이가 깊을 경우
스택이 깨지면서 프로그램이 예측 불가능하게 죽는 문제가 발생한다.
이런 경우 해당 파일의 Stack 변수를 수정해주면 된다.
프로젝트를 생성해보지 않아서 잘 모르겠지만.. 아무튼 스택 크기는 512Byte(0x0200)으로 잡혀 있으니
용도에 맞게 설정하면 된다.

;******************************************************************************
;
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
;
;******************************************************************************
Stack   EQU     0x00000200   



Posted by 구차니
embeded/ARM2012. 4. 19. 19:31
KEIL로 컴파일 하면 아래와 같은 문구가 나오고
 Program Size: Code=34744 RO-data=11400 RW-data=1344 ZI-data=9872

의미는 아래와 같다.
1. ZI Data: Zero Initialized Data

2. RO Data are the constants.
Total
RAM Size = RW Data + ZI Data
Total ROM Size = Code + RO Data + RW Data

3. Some constants (RO data) are generated by the compiler/linker and might also be from libraries. So they will exist regardless that your program doesn't explicitly defines any constants. 

[링크 : http://www.keil.com/forum/10624/


글 완전 날로먹은듯? ㅋㅋㅋ

'embeded > ARM' 카테고리의 다른 글

TI DM368와 H-JTAG(실패)  (0) 2013.06.28
HibernateRTCSet  (0) 2012.04.19
타이머 핸들러 시간 충돌 안나게 조절하기?  (0) 2012.04.13
ti lm3s 시리즈 하이버네이트 모드 + RTC 사용하기  (2) 2012.04.04
TI LM3S1607 time epoch  (0) 2012.03.27
Posted by 구차니
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 구차니
embeded/80512009. 4. 13. 22:53
Summary           *** Error C249
                              Segment : Segment too large

Description        The compiler detected a data segment that was too large.
                        The maximum size of a data segment depends on memory space.

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

Segment too large는 데이터 저장부분에서 용량을 초과 할때 발생하는 것으로 보인다.
Memory Model을 Small Model 에서 Large Model로 교체하면 컴파일은 되지만, 제대로 실행이되는지는 모르겠다.

해결내용은 아래의 링크로
2009/04/14 - [AVR / 8051] - keil compiler - memory type (code,xdata,idata)

Posted by 구차니
embeded/80512008. 12. 7. 04:09
C51 Evaluation Tools
  • You may not use the Evaluation Version of the µVision IDE/Debugger to create commercial products.
  • The 8051 compiler, assembler, linker, and debugger are limited to 2 Kbytes of object code. Source code may be of any size.
  • Programs that generate more than 2 Kbytes of object code will not compile, assemble, or link.
  • The debugger supports programs that are 2 Kbytes or smaller.
  • The startup code generated includes LJMPs. Code generated cannot be used in single-chip devices that support 2 Kbytes or less of program space.
  • Programs start at offset 0x0800. Programs generated with the evaluation software may not be programmed into single-chip devices with less than 2 Kbytes of on-chip ROM.
  • No hardware support for multiple DPTR registers is provided.
  • No support for floating-point arithmetic and no support for user libraries is provided.
  • No support for in-line assembly using #pragma ASM.
  • The following components which are present in the PK51 Full Version are not included in the Evaluation Version: Linker for Code Banking, Library Manager, and RTX51 Tiny Real-time Operating System.

이름, 주소 , 전화 번호, 메일 정도의 개인 정보를 요구 하고 Evaluation 버전을 다운 받을 수 있다.
위에 적힌 대로 소스 사이즈는 상관없지만 object 파일은 2K까지만 제한이 되고, 부가적으로
2K 미만 메모리를 가진 칩용으로는 생성이 되지 않는다.(프로그램 시작 offset이 0x0800 으로 고정)
그리고 부동 소수점 / 사용자 라이브러리는 지원되지 않고 #pragma를 사용한 in-line 어셈블리가 지원되지 않는다.

일단 메모리가 4K 정도라면 2K 까지 프로그램까지 작성이 가능하다 라고 봐야 하나..
[링크 : http://www.keil.com/demo/limits.asp]

[다운링크 : http://www.keil.com/demo/]

'embeded > 8051' 카테고리의 다른 글

Keil compiler - Error : Segment too large  (0) 2009.04.13
8051 TIMER 에 대하여  (0) 2008.12.18
KEIL Cx51 - Warning L5: CODE SPACE MEMORY OVERLAP  (0) 2008.12.01
8051에 관하여  (0) 2008.11.28
KEIL Cx51 - 변수형  (0) 2008.11.25
Posted by 구차니
embeded/80512008. 12. 1. 13:24
케일 컴파일러에서 warning으로 발생하는데
처음에는 L5가 Line 5를 의미하는줄 알았는데 검색해보니 경고 번호 인듯 하다.(아마 Linker 5번째 경우의 경고?)

간단하게 시작 번지에서 끝 번지 사이의 코드들이 중첩(overlap) 되었다는 의미이고
원인은 동일 인터럽트 서비스 번호에 여러 함수를 작성했거나,
동일 번지에 여러개의 변수를 선언했기 때문이며(at은 번지 검사를 하지 않음)
해결책으로는 linker에서 작성된 MAP 파일을 찾아서 해결하라고 되어 있다.


링크 : http://www.keil.com/support/docs/839.htm
링크 : http://www.keil.com/support/man/docs/bl51/bl51_l5.htm

'embeded > 8051' 카테고리의 다른 글

Keil compiler - Error : Segment too large  (0) 2009.04.13
8051 TIMER 에 대하여  (0) 2008.12.18
Keil evaluation Limitation  (0) 2008.12.07
8051에 관하여  (0) 2008.11.28
KEIL Cx51 - 변수형  (0) 2008.11.25
Posted by 구차니
embeded/80512008. 11. 28. 23:32
8051 공부 하는데 필요한 사이트 몇개 발견

http://8052.com/
이름부터가 8052를 공부 한다면 당연히 외워야 할꺼 같다!!
공부 하는데 꽤 많은 도움을 주었던 8052 문서가 여기 tutorial이었다니 OTL

http://www.keil.com/support/man/docs/c51/
8051용 컴파일러중에 가장 유명할 듯한 KEIL 컴파일러 C51에 대한 설명서이다.
눈여겨 볼 부분은 8051에 특화된 부분인 Language Extensions 부분이다.
레지스터등의 설명은 8052.com을 참고하는 것이 좋다.

http://sdcc.sourceforge.net/
KEIL의 경우 데모 버전은 2KB 용량 제한/코드 시작 번지가 4000H로 고정 되는 제한이 있다고 하고
상용프로그램인 관계로 무료 공개 컴파일러를 필요로 한다면 SDCC 라는 컴파일러를 사용하면된다.
물론 keil의 language extions 부분에서 _at_ 지정자 등의 차이를 보인다.
(많이 사용해보지 않아서 발견한 부분은 _at_ 키워드 뿐이다)
KEIL 컴파일러의 경우에는 sdcc와는 반대 순서로 선언이 된다.
unsigned char test _at_ 0x00; 이라고 Keil에서 선언한다면
sdcc에서는
unsigned char at 0x00 test; 라고 선언이 된다.

[cross link : http://blog.naver.com/morpheuz82/130024216128]



http://www.ustr.net/
IR 관련 소스 및 정보도 풍부하고, 각종 유틸리티들이 download에 많이 있다
(잘 찾아 보면 디스어셈블러도!!)

'embeded > 8051' 카테고리의 다른 글

Keil compiler - Error : Segment too large  (0) 2009.04.13
8051 TIMER 에 대하여  (0) 2008.12.18
Keil evaluation Limitation  (0) 2008.12.07
KEIL Cx51 - Warning L5: CODE SPACE MEMORY OVERLAP  (0) 2008.12.01
KEIL Cx51 - 변수형  (0) 2008.11.25
Posted by 구차니
embeded/80512008. 11. 25. 16:05
sfr - Special Function Register
sbit - SFR Bit

sbit name = sfr-name ^ bit-position;
sbit name = sfr-address ^ bit-position;
sbit name = sbit-address;

두번째나 세번째나 매한가지 이지만, readability를 따지자면 1번이나 2번으로 하는 것이 좋을 듯 하다.

#define P0 0x80 // port 0 SFR address
sbit P0_1 = P0 ^ 1;
sbit P0_1 = 0x80 ^ 1;
sbit P0_1 = 0x81;

이런 방법으로 사용이 가능한데,
문제는 sfr 0x81은 SP로 정의 되어 있다. 이런 이유로 혼동의 여지가 있으므로 주의하는게 좋을 듯 하다.

세번째 방법의 경우,
0x80 + bit 식으로 사용하며 예를 들어 7번째 비트를 사용하고 싶다면 0x87을 사용하면 된다.
0xC8의 6번째를 사용하고 싶다면 0xC8 + 6 = 0xCE 가 된다.

제약 조건으로는 세번째 방법의 경우 lower nibble이 0이거나 8이어야 한다고 기술 되어 있는데,
다르게 말하자면
0x80인 P0은 sbit으로 사용가능하지만
0x81인 SP는 sbit으로 사용이 불가능하다.
간단하게 아래 표의 가장 왼쪽 라인의 P0 P1 P2 P3 P4 TCOn SCON IE IP T2CON PSW ACC B 만 사용가능할 듯 하다.




[sfr : http://www.keil.com/support/man/docs/c51/c51_le_sfr.htm]
[sbit : http://www.keil.com/support/man/docs/c51/c51_le_sbit.htm]

'embeded > 8051' 카테고리의 다른 글

Keil compiler - Error : Segment too large  (0) 2009.04.13
8051 TIMER 에 대하여  (0) 2008.12.18
Keil evaluation Limitation  (0) 2008.12.07
KEIL Cx51 - Warning L5: CODE SPACE MEMORY OVERLAP  (0) 2008.12.01
8051에 관하여  (0) 2008.11.28
Posted by 구차니