embeded/80512009. 4. 21. 17:36
if(tempUnicode == 0x00E0)        output[out_idx] = 0x80;
else if(tempUnicode == 0x00E0) output[out_idx] = 0x80;
else if(tempUnicode == 0x00E0) output[out_idx] = 0x80;
...
else if(tempUnicode == 0x00E0) output[out_idx] = 0x80;
// 대략 128개

이녀석을 컴파일 하면
Program Size: data=189.7 xdata=0 code=10418

if(tempUnicode == 0x00E0)        res = 0x80;
else if(tempUnicode == 0x00E0) res = 0x80;
else if(tempUnicode == 0x00E0) res = 0x80;
...
else if(tempUnicode == 0x00E0) res = 0x80;
// 대략 128개

이녀석을 컴파일 하면
Program Size: data=187.7 xdata=0 code=9518


별거 아닌 코드이지만, 900byte 차이가 난다.
결론. 8051에서는 배열사용을 자제하자(switch / if-else 문처럼 한번의 액션에 분기되는 거라면)
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2009. 4. 20. 00:37
패러럴이면 STK-200 호환
USB면 STK-500 호환이라고 한다.


Valid programmers are:
  c2n232i  = serial port banging, reset=dtr sck=!rts mosi=!txd miso=!cts [/usr/local/etc/avrdude.conf:834]
  dasa3    = serial port banging, reset=!dtr sck=rts mosi=txd miso=cts [/usr/local/etc/avrdude.conf:821]
  dasa     = serial port banging, reset=rts sck=dtr mosi=txd miso=cts [/usr/local/etc/avrdude.conf:808]
  siprog   = Lancos SI-Prog <http://www.lancos.com/siprogsch.html> [/usr/local/etc/avrdude.conf:795]
  ponyser  = design ponyprog serial, reset=!txd sck=rts mosi=dtr miso=cts [/usr/local/etc/avrdude.conf:782]
  89isp    = Atmel at89isp cable            [/usr/local/etc/avrdude.conf:749]
  frank-stk200 = Frank STK200                   [/usr/local/etc/avrdude.conf:735]
  blaster  = Altera ByteBlaster             [/usr/local/etc/avrdude.conf:722]
  ere-isp-avr = ERE ISP-AVR <http://www.ere.co.th/download/sch050713.pdf> [/usr/local/etc/avrdude.conf:712]
  atisp    = AT-ISP V1.1 programming cable for AVR-SDK1 from <http://micro-research.co.th/>  [/usr/local/etc/avrdude.conf:702]
  dapa     = Direct AVR Parallel Access cable [/usr/local/etc/avrdude.conf:691]
  xil      = Xilinx JTAG cable              [/usr/local/etc/avrdude.conf:678]
  futurlec = Futurlec.com programming cable. [/usr/local/etc/avrdude.conf:661]
  abcmini  = ABCmini Board, aka Dick Smith HOTCHIP [/usr/local/etc/avrdude.conf:651]
  picoweb  = Picoweb Programming Cable, http://www.picoweb.net/ [/usr/local/etc/avrdude.conf:641]
  sp12     = Steve Bolt's Programmer        [/usr/local/etc/avrdude.conf:630]
  alf      = Nightshade ALF-PgmAVR, http://nightshade.homeip.net/ [/usr/local/etc/avrdude.conf:614]
  bascom   = Bascom SAMPLE programming cable [/usr/local/etc/avrdude.conf:604]
  dt006    = Dontronics DT006               [/usr/local/etc/avrdude.conf:594]
  pony-stk200 = Pony Prog STK200               [/usr/local/etc/avrdude.conf:582]
  stk200   = STK200                         [/usr/local/etc/avrdude.conf:566]
  bsd      = Brian Dean's Programmer, http://www.bsdhome.com/avrdude/ [/usr/local/etc/avrdude.conf:555]
  pavr     = Jason Kyle's pAVR Serial Programmer [/usr/local/etc/avrdude.conf:547]
  dragon_dw = Atmel AVR Dragon in debugWire mode [/usr/local/etc/avrdude.conf:540]
  dragon_hvsp = Atmel AVR Dragon in HVSP mode  [/usr/local/etc/avrdude.conf:532]
  dragon_pp = Atmel AVR Dragon in PP mode    [/usr/local/etc/avrdude.conf:524]
  dragon_isp = Atmel AVR Dragon in ISP mode   [/usr/local/etc/avrdude.conf:516]
  dragon_jtag = Atmel AVR Dragon in JTAG mode  [/usr/local/etc/avrdude.conf:508]
  jtag2dw  = Atmel JTAG ICE mkII in debugWire mode [/usr/local/etc/avrdude.conf:500]
  jtag2isp = Atmel JTAG ICE mkII in ISP mode [/usr/local/etc/avrdude.conf:492]
  jtag2    = Atmel JTAG ICE mkII            [/usr/local/etc/avrdude.conf:484]
  jtag2fast = Atmel JTAG ICE mkII            [/usr/local/etc/avrdude.conf:476]
  jtag2slow = Atmel JTAG ICE mkII            [/usr/local/etc/avrdude.conf:468]
  jtagmkII = Atmel JTAG ICE mkII            [/usr/local/etc/avrdude.conf:460]
  jtag1slow = Atmel JTAG ICE (mkI)           [/usr/local/etc/avrdude.conf:453]
  jtag1    = Atmel JTAG ICE (mkI)           [/usr/local/etc/avrdude.conf:445]
  jtagmkI  = Atmel JTAG ICE (mkI)           [/usr/local/etc/avrdude.conf:437]
  avr911   = Atmel AppNote AVR911 AVROSP    [/usr/local/etc/avrdude.conf:431]
  avr109   = Atmel AppNote AVR109 Boot Loader [/usr/local/etc/avrdude.conf:425]
  butterfly = Atmel Butterfly Development Board [/usr/local/etc/avrdude.conf:419]
  usbtiny  = USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/ [/usr/local/etc/avrdude.conf:413]
  usbasp   = USBasp, http://www.fischl.de/usbasp/ [/usr/local/etc/avrdude.conf:407]
  avr910   = Atmel Low Cost Serial Programmer [/usr/local/etc/avrdude.conf:401]
  stk600hvsp = Atmel STK600 in high-voltage serial programming mode [/usr/local/etc/avrdude.conf:395]
  stk600pp = Atmel STK600 in parallel programming mode [/usr/local/etc/avrdude.conf:389]
  stk600   = Atmel STK600                   [/usr/local/etc/avrdude.conf:383]
  stk500hvsp = Atmel STK500 V2 in high-voltage serial programming mode [/usr/local/etc/avrdude.conf:377]
  stk500pp = Atmel STK500 V2 in parallel programming mode [/usr/local/etc/avrdude.conf:371]
  stk500v2 = Atmel STK500 Version 2.x firmware [/usr/local/etc/avrdude.conf:365]
  mib510   = Crossbow MIB510 programming board [/usr/local/etc/avrdude.conf:359]
  stk500v1 = Atmel STK500 Version 1.x firmware [/usr/local/etc/avrdude.conf:353]
  stk500   = Atmel STK500                   [/usr/local/etc/avrdude.conf:347]
  avrisp2  = Atmel AVR ISP mkII             [/usr/local/etc/avrdude.conf:337]
  avrispmkII = Atmel AVR ISP mkII             [/usr/local/etc/avrdude.conf:331]
  avrispv2 = Atmel AVR ISP V2               [/usr/local/etc/avrdude.conf:325]
  avrisp   = Atmel AVR ISP                  [/usr/local/etc/avrdude.conf:319]
  arduino  = Arduino                        [/usr/local/etc/avrdude.conf:313]



Posted by 구차니
embeded/AVR (ATmega,ATtiny)2009. 4. 15. 00:17

avrdude를 막상 사용해보려니 막막해서.. 일단 이런녀석을 찾아 보게 되었다.
이거 말고도 존재하지만, 막상 실행하보니 윈도우용.. gnome용이나 Xwindow용으로 할 방법이 딱히 보이지 않아서
(게다가 g++도 설치가 되어 있지 않으니 ㄱ-) 포기를 할까 하다가 구글에서 조금 더 찾아 보니
gnome-avrdude라는 것을 발견하게 되었다.  아무튼 이녀석으로 나중에 AVR 읽어 보는 테스트를 해봐야겠다.

[발견 : korean.osstrans.net/software/gnome-avrdude.html]
[gnome-avrdude : http://sourceforge.net/projects/gnome-avrdude]

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

ubuntu에서 gnome-avrdude 사용하기  (0) 2009.05.27
STK-200 / STK-500 호환 AVR ISP  (2) 2009.04.20
linux에서 AVR 컴파일하기  (0) 2009.04.07
어셈블리 언어 ORG 명령  (4) 2009.03.19
AVR Studio / AVR-GCC 뜯어 보기  (0) 2008.11.18
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 구차니
linux에서는 gcc에서 옵션으로 지원을 한다고 한다.

AVR Options - Using the GNU Compiler Collection (GCC)

3.17.23 AVR Options

These options are defined for AVR implementations:

-mmcu=mcu
Specify ATMEL AVR instruction set or MCU type.

Instruction set avr1 is for the minimal AVR core, not supported by the C compiler, only for assembler programs (MCU types: at90s1200, attiny10, attiny11, attiny12, attiny15, attiny28).

Instruction set avr2 (default) is for the classic AVR core with up to 8K program memory space (MCU types: at90s2313, at90s2323, attiny22, at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515, at90c8534, at90s8535).

Instruction set avr3 is for the classic AVR core with up to 128K program memory space (MCU types: atmega103, atmega603, at43usb320, at76c711).

Instruction set avr4 is for the enhanced AVR core with up to 8K program memory space (MCU types: atmega8, atmega83, atmega85).

Instruction set avr5 is for the enhanced AVR core with up to 128K program memory space (MCU types: atmega16, atmega161, atmega163, atmega32, atmega323, atmega64, atmega128, at43usb355, at94k).

-msize
Output instruction sizes to the asm file.
-minit-stack=N
Specify the initial stack address, which may be a symbol or numeric value, `__stack' is the default.
-mno-interrupts
Generated code is not compatible with hardware interrupts. Code size will be smaller.
-mcall-prologues
Functions prologues/epilogues expanded as call to appropriate subroutines. Code size will be smaller.
-mno-tablejump
Do not generate tablejump insns which sometimes increase code size.
-mtiny-stack
Change only the low 8 bits of the stack pointer.


[링크 : http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/AVR-Options.html]

avrprog는 2001년 6월 이후로 업데이트 안되고 있고, avrdude가 계속 유지 되고 있는 듯 보인다.

[AVRPROG : http://sourceforge.net/projects/avrprog/]
[AVRDUDE : http://savannah.nongnu.org/projects/avrdude]
[gnome-avrdude : http://sourceforge.net/projects/gnome-avrdude]


아쉽게도 AVR Studio는 AVR32(32bit 버전)용 밖에 없다.

  AVR32 GNU Toolchain 2.1.6 - Linux Fedora 9 (27 MB, revision 2.1.6, updated 3/09) RPMs for Fedora Core 9.
  AVR32 Studio 2.1.1 for Linux (249 MB, revision 2.1.1, updated 2/09) AVR32 Studio package for Linux.
[atmel official : http://www.atmel.com/dyn/products/tools.asp?family_id=682]

참고 링크
[링크 : http://picky9.com/blog/entry/223]

Posted by 구차니
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 구차니