電子ブロック工房:
Deprecated: Function strftime() is deprecated in /home/u109394186/domains/rad51.net/public_html/jeans/jeans/libs/blog.php on line 333
2009年 10月の記事

Low Pin Count USB Development Kit [PIC]

2009年10月13日

PICをUSBでPCにつなげたい。日本に住んでいれば、PICで楽しむ USB機器自作のすすめ、この一冊を購入することから始めるのだろうけれど…。

とりあえず、Microchipの『Low Pin Count USB Development Kit』を試してみることにした。

実際にはこのキットは購入していない。購入せずとも、『Low Pin Count USB Development Kit User's Guide』が上記リンクからダウンロードできる。これを読んでみた所、PICkit2があればプログラミングできるようなので、とりあえずPIC18f14k50でのプログラミングがどんなものなのかを体験してみた。

CPU ver 0.0.7.1 [CPU]

2009年10月7日

CPUの規格を、変更。

data line: 8 bits
address line: 14 bits (8 bits + 6 bits; 256 x 64; 16K bytes)

registors A(8), F(8), PC(12), SP(8)
F: Z, C, S5, S4, S3, S2, S1, S0 (Z, C: zero and carry flags; S: segment registor)
stack segment is always 0x3f
program can be written from 0x0000 to 0x0fff (total 4K bytes)


All 2 byte commands

0x00, 0x01, ... , 0x0f: goto, operand: 12 bits.
0x10, 0x11, ... , 0x1f: call, operand: 12 bits.
0x20, 0x21, ... , 0x27: A=A+XX, A=A-XX, A=(XX), [A]=(XX), A=A&XX, A=A|XX, (XX)=A, (XX)=[A] 
0x2800 - 0x28ff: A=XX
0x2900 - 0x29ff: stack-using processes
    bit 0-1: A, reserved, F, or none
    bit 2: use also c7 for read/write
    bit 3: SP++ or SP-- at c4
    bit 4: SP++ or SP-- at c6
    bit 5: SP++ or SP-- at c8
    bit 6: 0: SP++, 1: SP--
    bit 7: 0: read, 1: write (c5)
0x2900 - 0x2907: A=[SP], reserved, F=[SP], reserved
0x2908 - 0x290f: [SP]=A, reserved, [SP]=F, reserved
0x2910 - 0x2917: pop A, reserved, pop F, SP++
0x2918 - 0x291f: [++SP]=A, reserved, [++SP]=F,
0x2920 - 0x2927: A=[SP++], reserved, F=[SP++],
0x2928 - 0x292f: [SP++]=A, reserved, [SP++]=F,
0x2930 - 0x2937: A=[++SP++], reserved, F=[++SP++], SP+=2, , , , return
0x2938 - 0x293f: [++SP++]=A, reserved, [++SP++]=F,
0x2960 - 0x2967: A=[SP++++], reserved, F=[SP++++], 
0x2968 - 0x296f: [SP++++]=A, reserved, [SP++++]=F,
0x2970 - 0x2977: A=[++SP++++], reserved, F=[++SP++++], SP+=3
0x2978 - 0x2978: [++SP++++]=A, reserved, [++SP++++]=F,
0x2990 - 0x2997: A=[--SP], reserved, F=[--SP], SP--
0x2998 - 0x299f: [--SP]=A, reserved, [--SP]=F,
0x29a0 - 0x29a7: A=[SP--], reserved, F=[SP--],
0x29a8 - 0x29af: push A, reserved, push F,
0x29b0 - 0x29b7: A=[--SP--], reserved, F=[--SP--], SP-=2
0x29b8 - 0x29bf: [--SP--]=A, reserved, [--SP--]=F,
0x29e0 - 0x29e7: A=[SP----], reserved, F=[SP----],
0x29e8 - 0x29ef: [SP----]=A, reserved, [SP----]=F,
0x29f0 - 0x29f7: A=[--SP----], reserved, F=[--SP----], SP-=3
0x29f8 - 0x29ff: [--SP----]=A, reserved, [--SP----]=F,
0x2a00 - 0x2a03: A=A (NOP), reserved, A=F, A=SP
0x2a04 - 0x2a07: reserved
0x2a08 - 0x2a0b: F=A, reserved, resreved, F=SP
0x2a0c - 0x2a0f: SP=A, reserved, SP=F, reserved
0x2a10 - 0x2aff: reserved
0x2b00 - 0x2dff: reserved
0x2e00 - 0x2eff: (XX)++
0x2f00 - 0x2fff: (XX)--

0x30, 0x31, ... , 0x38: A=A+(XX), A=A-(XX), A=A+(XX)+C, A=A-(XX)-C, A=A&(XX), A=A|(XX), A=A^(XX), A=~(XX)
0x39, 0x3a, ... , 0x3f: (XX)=(XX)+A, (XX)=(XX)-A, (XX)=(XX)+A+C, (XX)=(XX)-A-C, 
                        (XX)=(XX)&A, (XX)=(XX)|A, (XX)=(XX)^A, (XX)=~A
0x40, 0x41, ... , 0x4f: jz, operand: 12 bits.
0x50, 0x51, ... , 0x5f: jc, operand: 12 bits.
0x60, 0x61, ... , 0x6f: jnz, operand: 12 bits.
0x70, 0x71, ... , 0x7f: jnc, operand: 12 bits.
0x80, 0x81, ... , 0x8f: reserved
0x90, 0x91, ... , 0x9f: reserved
0xa0, 0xa1, ... , 0xaf: reserved
0xb0, 0xb1, ... , 0xbf: reserved
0xc0, 0xc1, ... , 0xcf: reserved
0xd0, 0xd1, ... , 0xdf: reserved
0xe0, 0xe1, ... , 0xef: reserved
0xf0, 0xf1, ... , 0xff: reserved

(XX) = [3Fh:XX]; used as registors; genelary, F8-FF (8 registors) are used.