embeded/AVR (ATmega,ATtiny)2009. 3. 19. 16:38
The ORG command is a standard (almost universal) command that tells the assembler where the program is to reside in memory

ORG 명령어는 메모리에 상주할 프로그램의 주소를 알려준다고 되어 있는데,
JMP 와는 다른 듯 한데 무슨 차이일려나..

[출처 :  www.ordersomewherechaos.com/rosso/fetish/m102/web100/docs/assemb-tutorial.html]
링크가 깨져, 구글에서 저장된 페이지로 보시기 바랍니다.


23. ORG
Label     Operation   Operand
optional     ORG      expression

The ORG directive instructs the assembler to continue the assembly from the
memory location specified by the operand. The operand must be an expression
that can be immediately evaluated, and its value must be a valid address (i.e., it
cannot be negative). Thus the operand can be a number, a known symbol, or an
expression that can be evaluated by the assembler at this point. Such an operand
is called “definable.”

[출처 : http://www.davidsalomon.name/assem.advertis/asl.pdf]


ORG expression
Sets the location counter to expression.
[출처 : MASM reference]
Posted by 구차니
embeded/i2c2009. 1. 14. 16:08
SMBus는 예전에는 안보였는데, 어느샌가 부터 야곰야곰 보이기 시작한 녀석이다.
눈에 띄기 시작한건 아마도.. 2기가 급이 넘어 가면서 부터였던것 같다.(노트북 제외)

그냥 머하는건지 BUS인가 보다 넘어 갔는데 문득 호기심이 발동하였다.

I2C 처럼 BUS 방식의 시리얼 통신이고, 전원관리 칩들, 온도, 팬 , 전압 센서등 연결하고 있다고 한다.
예전 같으면 BIOS에서 cpu / chasis / system 온도계 3개만 지원했는데 비해서
요즘에는 센서들이 너무 많아서 일일이 하나의 GPIO를 할당하기에는 무리가 있어서 BUS로 돌렸나보다.

The System Management Bus (abbreviated to SMBus or SMB) is a simple two-wire bus, derived from I²C and used for communication with low-bandwidth devices on a motherboard, especially power related chips such as a laptop's rechargeable battery subsystem (see Smart Battery Data). Other devices might include temperature, fan or voltage sensors, lid switches and clock chips. PCI add-in cards may connect to an SMBus segment

The SMBus was defined by Intel in 1995. It carries clock, data, and instructions and is based on Philips' I²C serial bus protocol. Its clock frequency range is 10 kHz to 100 kHz. (PMBus extends this to 400 kHz.) Its voltage levels and timings are more strictly defined than those of I²C, but devices belonging to the two systems are often successfully mixed on the same bus.


[SMBus wikipedia : http://en.wikipedia.org/wiki/System_Management_Bus]

Differences between I2C and SMBus

In general, the I2C bus and SMBus are compatible, but there are some subtle differences between the two that could cause some problems. The following table summarizes the differences between the two buses.


I2C SMBus
Clock Speed
Minimum none 10 kHz
Maximum
100 kHz (Standard mode)
400 kHz (Fast mode)
2 MHz (High Speed mode)
100 kHz
Timeout none 35 ms

Electrical Characteristics
VHIGH
Fixed Voltage 3.0 to VDDmax + 0.5V
VDD Relative 0.7 to VDDmax + 0.5V
2.1V -> VDD
VLOW
Fixed Voltage -0.5 to 1.5
VDD Relative -0.5 to 0.3VDD
to 0.8V
Max Current 3 mA 350 µA


[출처 : http://www.totalphase.com/support/articles/article06/]

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

i2c mode - tm4c  (0) 2018.04.26
i2c BUS에 pull-up, pull-down  (0) 2018.04.26
i2c bank switching  (0) 2015.09.02
i2c 정리  (4) 2012.01.10
I2C  (2) 2011.11.28
Posted by 구차니
embeded/80512008. 12. 18. 00:04
TIMER/COUNTER는 숫자가 클럭 마다 1씩 증가 한다.
8051의 경우에는 입력 클럭을 1/12 로 분기 해서 사용하므로
11.0592Mhz로 할 경우에 1초당 921,600 연산이 가능하다.
(반대로 이야기 하자면 921,600 카운트가 진행되면 1초라는 의미이지만,
16bit 카운터로는 65536이 한계이므로 0.07초 70ms가 측정 가능한 최고 시간이다)

일단 타이머와 카운터는 인터럽트나 이런것의 영향 없이 독립적으로 증가 하므로,
정확하게 시간을 측정할 수 있는데

내가 원하는 시간을 재기 위해서 어떻게 카운터를 설정하냐는 것이 문제였다.
(물론 알고 나니 그럴 고민 조차 의미가 없었지만 ㄱ-)

prescaler를 설정해서 1clock에 증가하는 숫자가 1이 아니어서 원하는 횟수를 돌고(원하는 시간후에)
timer/counter overflow interrupt를 발생시키는 것으로 알고 있었는데..

8051에는 일단 timer/counter에 대한 prescaler가 존재 하지 않는다.
(prescaler를 잘못 이해 한것인지는 모르겠지만..)

즉, 원하는 시간을 클럭으로 계산후에
Timer/counter의 초기 값을 설정해주고, 그 값이 overflow 되기를 기다리면 되는 것 이었다.

예를 들어 1ms 를 원한다면
1초 = 1000ms 이므로
대략 921.6 clock 후에는 overflow가 되도록 설정을 해야 하고
256을 넘어 서므로 16bit 카운터로 설정하여
16bit 카운터의 최대 값에서 원하는 시간을 뺀
"65536 - 921 = 64615 = 0xFC67" 을 타이머에 설정을 해주면
원하는 시간인 1ms 후에 overflow가 발생하게 된다.

그리고 overflow 이후에는 0으로 리셋되므로
overflow ISR(Interrupt Service Routine)에는 매번 타이머/카운터를  설정을 해주어야
주기적으로 시간을 측정할 수 있게 된다.

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

keil compiler - memory type (code,xdata,idata)  (0) 2009.04.14
Keil compiler - Error : Segment too large  (0) 2009.04.13
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 구차니
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 구차니
embeded/AVR (ATmega,ATtiny)2008. 11. 18. 00:15

AVR Studio 에서는 상당 부분이 자동으로 생성된다. (source가 아니라 makefile)
AVR 프로그래밍 처음 단계는 아마도
#include <avr/io.h>가 아닐까 싶은데 이부분을 추적을 해 보았다.

makefile - 자동생성

MCU 에 AVR Studio에서 프로젝트 생성시 선택된 프로세서의 타입이 지정되고
아래의 COMMON 에 -mmcu=atmega128 로 확장이 된다. 일단 avr-gcc의 도움말을 보자면

Usage: avr-gcc [options] file...
Options:
  -pass-exit-codes         Exit with highest error code from a phase
  --help                   Display this information
  --target-help            Display target specific command line options
  --help={target|optimizers|warnings|undocumented|params}[,{[^]joined|[^]separate}]
                           Display specific types of command line options
  (Use '-v --help' to display command line options of sub-processes)
  -dumpspecs               Display all of the built in spec strings
  -dumpversion             Display the version of the compiler
  -dumpmachine             Display the compiler's target processor
  -print-search-dirs       Display the directories in the compiler's search path

  -print-libgcc-file-name  Display the name of the compiler's companion library
  -print-file-name=<lib>   Display the full path to library <lib>
  -print-prog-name=<prog>  Display the full path to compiler component <prog>
  -print-multi-directory   Display the root directory for versions of libgcc
  -print-multi-lib         Display the mapping between command line options and
                           multiple library search directories
  -print-multi-os-directory Display the relative path to OS libraries
  -print-sysroot-headers-suffix Display the sysroot suffix used to find headers
  -Wa,<options>            Pass comma-separated <options> on to the assembler
  -Wp,<options>            Pass comma-separated <options> on to the preprocessor

  -Wl,<options>            Pass comma-separated <options> on to the linker
  -Xassembler <arg>        Pass <arg> on to the assembler
  -Xpreprocessor <arg>     Pass <arg> on to the preprocessor
  -Xlinker <arg>           Pass <arg> on to the linker
  -combine                 Pass multiple source files to compiler at once
  -save-temps              Do not delete intermediate files
  -pipe                    Use pipes rather than intermediate files
  -time                    Time the execution of each subprocess
  -specs=<file>            Override built-in specs with the contents of <file>
  -std=<standard>          Assume that the input sources are for <standard>
  --sysroot=<directory>    Use <directory> as the root directory for headers
                           and libraries
  -B <directory>           Add <directory> to the compiler's search paths
  -b <machine>             Run gcc for target <machine>, if installed
  -V <version>             Run gcc version number <version>, if installed
  -v                       Display the programs invoked by the compiler
  -###                     Like -v but options quoted and commands not executed
  -E                       Preprocess only; do not compile, assemble or link
  -S                       Compile only; do not assemble or link
  -c                       Compile and assemble, but do not link
  -o <file>                Place the output into <file>
  -x <language>            Specify the language of the following input files
                           Permissible languages include: c c++ assembler none
                           'none' means revert to the default behavior of
                           guessing the language based on the file's extension

Options starting with -g, -f, -m, -O, -W, or --param are automatically
 passed on to the various sub-processes invoked by avr-gcc.  In order to pass
 other options on to these processes the -W<letter> options must be used.

For bug reporting instructions, please see:
<URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&func=browse>.

-m 의 경우 avr-gcc 에 의해서 생성된 하위 프로세서로 자동적으로 넘겨져서 처리가 된다고 한다.
아무튼 처음에 설정하는 <avr/io.h> 는 컴파일러의 include 디렉토리에 위치하는데
기본값으로 설치를 했다면 아래의 경로에 위치하게 된다.


이 파일들 중에서 우리가 보고 싶은것은 io.h 인데 이 파일을 열어 보면


와 같이 #if #elif 로 묶여 있고 그 중에 우리가 찾던
__AVR_ATmega128__ 이라는 선언이 존재 한다. 아마도 -mmcu=atmega128이 이런식으로 치환이 되는 듯 하다.


아무튼 치환될 iom128.h 파일을 열어 보면 우리가 사용하는 일반적인 용어(!) 인
PINA DDRA 등의 선언과 그 에 상응하는 주소를 볼 수 있다.
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2008. 11. 10. 00:21
요즘에는 대부분의 메인보드에 USB만 있을뿐 LPT(패러럴)나 COM(시리얼)이 없는 경우도 상당히 많다.
하지만 AVR을 프로그래밍 하려면 롬 라이터가 있어야 하는데,
이 장비의 경우 고가인데다가, 칩의 핀수에 맞는 커넥터를 구매 하여야 한다.

그런 이유로 현실적인 대안은 USB 시리얼/패러럴이나
시리얼 / 패러럴이 달린 구형 메인보드, 혹은 최상급의 메인보드를 구매 해야 한다.

그렇다고 하기에는 이래저래 돈이 많이 드는 관계로 조금이라도 덜 들고 편한쪽을 택하라면
USB ISP를 구매 하는게 좋을듯 하다.

유니텍의 경우 패러럴 포트를 내부에 26핀으로 별도로 꺼내서 유니텍에서 별도 판매 하는
패러럴 포트를 구매 하면 되지만, 이래저래 가격 부담도 크고, 유니텍스럽게 택배비는 착불이라서 기분도 나쁘고
그냥 USB ISP를 사는게 가장 효율적인 방안으로 생각이 된다.


---
나머지는 구매 후 적도록 ^^;
STK-500 이라는 것과 호환이 되고, USB-ISP 역시 일종의 USB 시리얼로 COM포트로 인식하고
(보드는 USB 시리얼 + STK500 제어용 칩으로 구성) 시리얼로 프로그램을 전송한다.
데이터 시트 상으로는 시리얼 프로그래밍에 관한 항목이 있으므로 이부분을 좀더 읽어 봐야 할 듯 하다.
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2008. 11. 7. 23:05
결론 : 실패
원인 : 아직 모름..

일단 Ponyprog에서 포트 자동 탐지를 끄라고 한다.
  • PonyProg2000 (Freeware programmer esp. for PIC, ATmega, serial EEPROMs)
    • The INI file must be modified to get PonyProg to work: change „AutoDetectPorts=NO“!

[출처 : http://www-user.tu-chemnitz.de/~heha/bastelecke/Rund%20um%20den%20PC/USB2LPT/liste.htm.en]

일단 ponyprog.ini의 내용은 아래와 같다.



그리고 나서 해보니 먼가 되는듯한데.. 여전히 -16오류, 장치를 발견하지 못한다고 한다.
그래서 계속 검색을 해보니.. 그런 이유로 USB ISP가 나온거라는 식으로 되어 있어서 좌절 OTL

USB LPT / 도킹 전부 임베디드 장비에서 패러럴이 아닌 프린트 포트로 인식을 해서 안된대나..
일부 외국산 장비중에는 인식하는것도 있지만 강원전자꺼는 드라이버 문제인지 안된다고 한다.

[링크 : http://kldp.org/node/46808]
Posted by 구차니