SPI command utility.

Backup of earlier posts.
Post Reply
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

SPI command utility.

Post by usbbdm »

This only for advanced user! I can not support each one. Post your quesion here.

1. First download dcttest.zip 0.13
http://www.usbjtag.com/download/dcttest.zip
extract to your BDM directory.
2. Dwonload SPI commander
http://www.usbjtag.com/download/SPIcommand.zip
3. Run the BDM.
Under DCT Test, select "SPI Commander"
Type the command

Code: Select all

reset 1
init
setram ea0000 500
go= ea0000
Do not touch the BDM software, the box is now ready read serial command sne send to XC chip and disply the responce.
4. Run SPI commander application.

Here are some command to start.

s 2
s 0 0 0
s 86 18
s 2
s 0 0 0
s 86 18
g 2 1 0
g 5 0
g 4 0
g 6 0
patsfan
Junior Member
Posts: 673
Joined: Thu Jul 21, 2005 4:02 pm

Post by patsfan »

well i consider myself an advanced user, but.......

what do these commands mean/do?

s 2
s 0 0 0
s 86 18
s 2
s 0 0 0
s 86 18
g 2 1 0
g 5 0
g 4 0
g 6 0


does anyone have link to spi commands? thanks
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

Post by usbbdm »

If you have used SPI log, you should noticed your box first started with

02
00

00 00 00
05 00 00

86 18
00 00

...

In SPI commander,
"s" is for send a command series.

"g" is get parameter which will automatically generate the checksum and header.
eg.
g 2 1 0
will have
80 02 01 00 03
55 00 00 00 00

00
55

00 00
02 01

01
55

00 00
00 03

Get paramter is five commands which will complete with "g" command.

Any time you see XC responce 11, means the XC chip is in bad state and will not work any more.
Here is a sequeence to get it back. (Found in firmware)

s 86 9
s 86 8
s 86 18
s 2
s 0 0 0
s 86 18
g 2 1 0
...
kai
Junior Member
Posts: 34
Joined: Thu Jul 28, 2005 12:54 pm

Post by kai »

I'm not getting any response at all. The characters I type in SPICommand don't even echo back. I typed in the commands just like the prompts say to after I select SPICommander in the BDM. I double checked my serial connection using the spilog program and that's all fine.
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

Post by usbbdm »

kai wrote:I'm not getting any response at all. The characters I type in SPICommand don't even echo back. I typed in the commands just like the prompts say to after I select SPICommander in the BDM. I double checked my serial connection using the spilog program and that's all fine.
Anybody has the same problem?
mamboswing
Junior Member
Posts: 70
Joined: Fri Jul 22, 2005 4:26 am

Post by mamboswing »

same here
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

Post by usbbdm »

OK. The conecpt is to run the loaded application. The box should not be functional in the mode.
To do this follow the procedure to go= ea0000
Then the Windows app is to send and receive via serial port.
If the box is not in that mode, then your box will not respond.

If you can not use SPI Log then your computer does not have the proper setting.
The app uses COM1 of your computer and only one app can use it.

Anyone has been able to use SPI command, please post how you set it up. I might use the language that is hard to understand by someone.
kai
Junior Member
Posts: 34
Joined: Thu Jul 28, 2005 12:54 pm

Post by kai »

I think what's happening is that the program keeps looping at the first subroutine at ea003ce. I always have a 00000180 in d0, then after the AND with 40, the result is always 00. What does that code do there? Can you post the source for that ea0000 section?

I think your instructions are clear enough, but for some reason it works for you and not me and mamboswing.
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

Post by usbbdm »

Kei. Per your request.

Code: Select all

DataBuf     equ     $E90000
DataBuf1    equ     $E90080
DataDef     equ     $E90010
    org $EA0000
SPIInit:
    MOVE.L A2,-(A7)
*QSMCR 
    MOVE.W #$4081,$00FFFC00.L
    MOVE.B $00FFFC04.L,D0
    ANDI.B #$C7,D0
    ORI.B #$18,D0
* QILR interrupt
    MOVE.B D0,$00FFFC04.L
* Interrupt vector register
    MOVE.B #$58,$00FFFC05.L
*QSM port data register
    MOVE.W #$0008,$00FFFC14.L
*QSM Pin assignment , Data direction
    MOVE.W #$0B7E,$00FFFC16.L   
* Control register
    MOVE.W #$8106,$00FFFC18.L
    MOVE.W $00FFFC1A.L,D0
    ANDI.W #$FF00,D0
    ORI.W #$0020,D0
    MOVE.W D0,$00FFFC1A.L
    ANDI.W #$FFF0,$00FFFC1C.L
    MOVEA.L (A7)+,A2

    MOVE.L #DataBuf1,A2
    MOVE.L #DataDef,(A2)

* serial port init
    MOVE.W #22,$00FFFC08.L        ; 38400
    MOVE.W #$0E0C,$00FFFC0A.L

ForEver:
    MOVEQ #00,D0
    BSR GetOneChar              ; number of bytes
    MOVE.L D0,D1
    MOVE.L D0,D3
    MOVE.L #DataDef,A3
    BRA  GetGetDataLoopLoc1
GetGetDataLoop:
    BSR GetOneChar
    MOVE.B D0,(A3)+
GetGetDataLoopLoc1:
    DBRA D3,GetGetDataLoop
    MOVE.B D1,($0005,A2)
    MOVE.L A2,-(A7)
    BSR SPISendCmd
    ADDQ.L #$4,A7
* send to serial port
    MOVEQ #0,D3
    MOVE.B ($0005,A2),D1
    MOVE.B D1,D3
    ANDI.B #$FE,D3
    BTST.B #0,D1
    BEQ Loc1
    MOVE.L #$00FFFD00,A5
    MOVE.B ($0001,A5,D3.W),D0
    MOVE.B D0,($0000,A5,D3.W)
Loc1:
    MOVE.L D1,D3
    MOVE.L #$00FFFD00,A3
    BRA GetSendDataLoopLoc1
GetSendDataLoop
    MOVE.B (A3)+,D0
    BSR SendOneChar
GetSendDataLoopLoc1:
    DBRA D3,GetSendDataLoop
    BRA ForEver
    BGND
    RTS


    MOVE.L #DataBuf1,A6
    MOVE.L #0,D4
SPILoop:
    MOVE.B (A3)+,D5         ; attribute
    CMP.B #0,D5
    BEQ SPIExit
    MOVE.L #DataBuf,A2
    MOVE.L A6,(A2)
    CMP.B #1,D5             ; Send one command
    BEQ SPILoc1
    CMP.B #2,D5
    BEQ SPILoc1
    CMP.B #3,D5
    BEQ SPILoc2
    CMP #4,D5
    BEQ SPILoop
    BRA SPIExit             ; illegal
SPILoc2:
    MOVE.B (A3)+,D4
    MOVE.B D4,($0005,A2)
    MOVE.L A3,(A2)
    ADD.L D4,A3
    MOVE.L A2,-(A7)
    BSR SPISendCmd
    ADDQ.L #$4,A7
    BRA SPILoop
SPILoc1:
    MOVE.B (A3)+,D4
    MOVE.B D4,($0005,A2)
    MOVE.B (A3)+,D0
    MOVE.B D0,($0006,A2)
    MOVE.L A2,-(A7)
    BSR SPIGetParam
    ADDQ.L #$4,A7
    MOVE.B ($0001,A6),D0
    ADD.B #1,D0
    MOVE.B D0,($0005,A2)
    MOVE.B #1,($0006,A2)
    ADD.L D4,A6
    MOVE.B D0,D4
    CMP.B #2,D5
    BNE SPILoop
    MOVE.L A6,(A2)
    MOVE.B #1,($0006,A2)
    MOVE.L A2,-(A7)
    BSR SPIGetParam
    ADDQ.L #$4,A7
    ADD.L D4,A6
    MOVE.B D0,D4
    BRA SPILoop
SPIExit:
    BGND
    RTS

SPIGetParam:
    MOVEM.L A2-A3/D2-D5,-(A7)
    MOVEA.L ($001C,A7),A2
    MOVEA.L (A2),A3
    MOVE.B ($0005,A2),D3
    MOVE.B D3,D4
    ANDI.B #$FE,D4
    MOVE.B D3,D0
    MOVEQ #$00,D0
    MOVE.B ($0006,A2),D0
    MOVE.W D0,$00FFFD20.L
    PEA $0001.W
    BSR SPISndRecv
    ADDQ.L #$4,A7
    MOVE.L D0,D2
    BNE SPIGetParamLoc2
    CMPI.B #$55,$00FFFD01.L
    BEQ SPIGetParamLoc1
SPIGetParamLoc2:
    MOVE.L #$0000C004,D2
SPIGetParamLoc1:
    TST.L D2
    BNE SPIGetParamLoc3
    PEA $0020.W
    CLR.L -(A7)
    MOVE.L #$00FFFD20,-(A7)
    JSR memset
    LEA ($000C,A7),A7
    MOVE.B D3,D0
    MOVE.L D0,-(A7)
    BSR SPISndRecv
    ADDQ.L #$4,A7
    MOVE.L D0,D2
    BNE SPIGetParamLoc4
    TST.B D4
    BEQ SPIGetParamLoc5
    CMPA.L #$00FFFD00,A3
    BEQ SPIGetParamLoc5
    MOVEQ #$00,D0
    MOVE.B D4,D0
    MOVEA.L #$00FFFD00,A0
    MOVEA.L A3,A1
    BRA SPIGetParamLoc6
SPIGetParamLoc7:
    MOVE.B (A0)+,(A1)+
SPIGetParamLoc6:
    SUBQ.L #$1,D0
    BGE SPIGetParamLoc7
SPIGetParamLoc5:
    BTST.L #$00,D3
    BEQ SPIGetParamLoc3
    MOVEQ #$00,D0
    MOVE.B D3,D0
    ASR.L #$1,D0
    ADD.L D0,D0
    MOVEA.L D0,A0
    MOVE.W ($FFFD00,A0),D0
    MOVEQ #$00,D1
    MOVE.B D4,D1
    MOVE.B D0,($0000,A3,D1.L)
    BRA SPIGetParamLoc3
SPIGetParamLoc4:
    MOVE.L #$0000C005,D2
SPIGetParamLoc3:
    MOVE.L D2,D0
    MOVEM.L (A7)+,A2-A3/D2-D5
    RTS

SPISendCmd:
    MOVEM.L A2-A3/D2-D6,-(A7)
    MOVEA.L ($0020,A7),A3
    MOVE.L #$0000C004,D6
    MOVEA.L (A3),A2
    MOVE.B ($0005,A3),D3
    MOVE.B D3,D4
    ANDI.B #$FE,D4
    TST.B D4
    BEQ SPISendCmdLoc1
    CMPA.L #$00FFFD20,A2
    BEQ SPISendCmdLoc1
    MOVEQ #$00,D0
    MOVE.B D4,D0
    MOVEA.L A2,A0
    MOVEA.L #$00FFFD20,A1
    BRA SPISendCmdLoc2
SPISendCmdLoc3:
    MOVE.B (A0)+,(A1)+
SPISendCmdLoc2:
    SUBQ.L #$1,D0
    BGE SPISendCmdLoc3
SPISendCmdLoc1:
    BTST.L #$00,D3
    BEQ SPISendCmdLoc8
    MOVEQ #$00,D0
    MOVE.B D4,D0
    MOVE.B ($0000,A2,D0.L),D0
    ANDI.L #$000000FF,D0
    MOVEQ #$00,D1
    MOVE.B D3,D1
    ASR.L #$1,D1
    ADD.L D1,D1
    MOVEA.L D1,A0
    MOVE.W D0,($FFFD20,A0)
SPISendCmdLoc8:
    MOVE.B D3,D0
    MOVE.L D0,-(A7)
    BSR SPISndRecv
    ADDQ.L #$4,A7
    MOVE.L D0,D2
    CMPI.B #$01,D3
    BLS SPISendCmdLoc7
    MOVEQ #$00,D3
    MOVE.W $00FFFD00.L,D3
    ASR.L #$8,D3
    BRA SPISendCmdLoc6
SPISendCmdLoc7:
    MOVE.B $00FFFD01.L,D3
SPISendCmdLoc6:
    MOVE.B D3,(A6)+
    CMPI.B #$55,D3
    BEQ SPISendCmdLoc5
    MOVE.L D6,D2
SPISendCmdLoc5:
    TST.L D2
    BEQ SPISendCmdExit
    MOVE.L D6,D2
SPISendCmdExit:
    MOVE.L D2,D0
    MOVEM.L (A7)+,A2-A3/D2-D6 
    RTS                     


SPISndRecv:
	MOVEM.L A2-A3/D2-D5,-(A7)
    MOVE.L #$E,D2
    MOVE.L ($001C,A7),D4
    MOVE.L #$00008000,D5
    MOVEQ #$00,D3
    MOVE.B D4,D3
    ASR.L #$1,D3
    TST.W D3
    BEQ SPISndRecv1
    MOVEQ #$00,D0
    MOVE.W D3,D0
    MOVE.L D0,-(A7)
    MOVEQ #$00,D0
    MOVE.B D2,D0
    ORI.W #$00E0,D0
    MOVE.L D0,-(A7)
    MOVE.L #$00FFFD40,-(A7)
    JSR memset
    LEA ($000C,A7),A7
SPISndRecv1:
    BTST.L #$00,D4
    BEQ SPISndRecv2
    MOVE.B D2,D0
    ORI.B #$20,D0
    MOVEQ #$00,D1
    MOVE.W D3,D1
    MOVEA.L D1,A0
    MOVE.B D0,($FFFD40,A0)
    BRA SPISndRecv3
SPISndRecv2:
    MOVE.B D2,D0
    ORI.B #$60,D0
    MOVEQ #$00,D1
    MOVE.W D3,D1
    MOVEA.L D1,A0
    MOVE.B D0,($FFFD3F,A0)
    ADDI.W #$FFFF,D3
SPISndRecv3:
    MOVE.W D3,D0
    LSL.W #$8,D0
    ANDI.W #$0F00,D0
    MOVE.W $00FFFC1C.L,D1
    ANDI.W #$F0FF,D1
    OR.W D1,D0
    MOVE.W D0,$00FFFC1C.L
*enable interrupt?
*    OR.W D0,$00FFFC1C.L
    MOVE.W D5,D0
    OR.W D0,$00FFFC1A.L
* test to see if end
SPISndRecvLoop:
    MOVE.B #$80,D0
    AND.B $00FFFC1F.L,D0
    BEQ SPISndRecvLoop
* clear the busy flag
    MOVE.B #$F7,D0
    AND.B D0,$00FFFC1F.L
    MOVE.L #0,D0
	MOVEM.L (A7)+,A2-A3/D2-D5
    RTS                                   ;

memset:
    MOVEA.L ($0004,A7),A1
    MOVE.L ($000C,A7),D1
    MOVEA.L A1,A0
    BEQ memsetLoc2
    MOVE.B ($000B,A7),D0
memsetLoc1:
    MOVE.B D0,(A0)+
    SUBQ.L #$1,D1
    BNE memsetLoc1
memsetLoc2:
    MOVE.L A1,D0
    RTS

GetOneChar
    MOVE.W $00FFFC0C.L,D0
    ANDI.L #$00000040,D0           ; receive data ready
    BEQ GetOneChar
    MOVE.W $00FFFC0E.L,D0
    AND.L #$FF,D0
    RTS

SendOneChar:
    MOVE.L D1,-(A7)
sendloop:
    MOVE.W $00FFFC0C.L,D1
    ANDI.L #$00000100,D1           ; if I can send
    BEQ sendloop
    AND.L #$FF,D0
    MOVE.W D0,$00FFFC0E.L
    MOVE.L (A7)+,D1
    RTS

    end
kai
Junior Member
Posts: 34
Joined: Thu Jul 28, 2005 12:54 pm

Post by kai »

Thanks for posting the source!

I tried a different computer and a different dct2244. Before I used an XP with a PH8, now I'm using Win2k and a PH7.

From what I can tell, I never get the "receive data ready" bit set on the very first call to GetOneChar. Right after that, you set the A3 register to #DataDef, and that never gets set unless I "NOP" that call to GetOneChar.

Very strange. Hopefully someone else who gets it working can help.

Question 1--When you start the SpiCommand program, does any data get displayed before you type something in?

Question 2--When you type commands, do they echo on the screen?

NOTE: IF I issue RESET on the BDM and the cable box comes on, data does get displayed, so I am connected to COM 1.
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

Post by usbbdm »

I think you have the right setup.

When wwe send command s 2 (int the low command window)
the
02
55

will show on the screen.

Can you send me your screen capture of the problem when you type in the command?
kai
Junior Member
Posts: 34
Joined: Thu Jul 28, 2005 12:54 pm

Post by kai »

Ok, I sent you an email with the screen cap.
kai
Junior Member
Posts: 34
Joined: Thu Jul 28, 2005 12:54 pm

Post by kai »

Oh hell!!! There is a lower command window that I didn't see until I grabbed it and pulled it up! It was completely covered, so I didn't even know it was there.

I kept reading your last post, and I finally understood what you meant.

Now it works, of course!
usbbdm
Junior Member
Posts: 8962
Joined: Mon Jul 18, 2005 9:33 pm

Post by usbbdm »

kai, I saw your message and I think it is your screen res is too low and the app automatically adjusted.

As Kai said, there should be a command window like usbbdm software. If you do not se it, you need to drag the mouse to see the window.
kai
Junior Member
Posts: 34
Joined: Thu Jul 28, 2005 12:54 pm

Post by kai »

It opens that way on my 1024x768 computer also. Maybe you could use an ini file so the program opens as 2 windows?

It's so obvious now. I can't believe I didn't think to check that first!

Anyway, I'm getting a better idea of how the spi commands work now.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests