I added the following routine for my 8052 chip to control an ISD1790py serially.
The Slave select line is always tied low.
My board contains circuitry in which it inverts some lines required for correct operation.
I have reflected this in the code.
The problem I am having is the actual bit shifting. I don't know if my code is decent enough.
Basically I'm trying to do a condensed version of this code:
The number of bytes to be sent to ISD1790py (which I'll call ISD from here on in) is variable
depending on the command I want to use.
I tried my code below and all I get in return is nothing. When I perform the initialization
with the proper opcode (setting first byte to 1 and second to 0), at least one bit in return
needs to be set to 1 but all I get is all bits clear.
Is there another way I can rewrite this code so the ISD is satisfied with
what I throw at it without having to rewrite the same kind of lines over again
like in the first code?
I looked at page 31 of the guide for my chip found at http://www.microtechnica.tv/support/manual/ISD1700_Design_Guide.pdf and I don't know if my code is quite right.
The Slave select line is always tied low.
My board contains circuitry in which it inverts some lines required for correct operation.
I have reflected this in the code.
The problem I am having is the actual bit shifting. I don't know if my code is decent enough.
Basically I'm trying to do a condensed version of this code:
Code:
mov C,datain
cpl C
cjne R5,#2h,nottwo
mov A,BYTE2
rrc A
mov BYTE2,A
mov A,BYTE1
rrc A
mov BYTE1,A
nottwo:
cjne R5,#3h,notthree
mov A,BYTE3
rrc A
mov BYTE3,A
mov A,BYTE2
rrc A
mov BYTE2,A
mov A,BYTE1
rrc A
mov BYTE1,A
notthree:
cjne R5,#5h,notfive
mov A,BYTE5
rrc A
mov BYTE5,A
mov A,BYTE4
rrc A
mov BYTE4,A
mov A,BYTE3
rrc A
mov BYTE3,A
mov A,BYTE2
rrc A
mov BYTE2,A
mov A,BYTE1
rrc A
mov BYTE1,A
notfive:
mov dataout,C
depending on the command I want to use.
I tried my code below and all I get in return is nothing. When I perform the initialization
with the proper opcode (setting first byte to 1 and second to 0), at least one bit in return
needs to be set to 1 but all I get is all bits clear.
Code:
ASPIS equ 23h ;SPIS=SPI workspace lower boundary address only
ASPID equ 24h ;SPI data space
;Data types to send to ISD
ASPIOCMD equ ASPID
ASPIOD1 equ ASPID+1
ASPIOD2 equ ASPID+2
ASPIOSA1 equ ASPID+2
ASPIOD3 equ ASPID+3
ASPIOSA2 equ ASPID+3
ASPIOEA1 equ ASPID+4
ASPIOEA2 equ ASPID+5
ASPIOEA3 equ ASPID+6
;Values receivable from ISD
ASPISR0 equ ASPID
ARERR equ ASPISR0.0
ARFULL equ ASPISR0.1
ARPU equ ASPISR0.2
AREOM equ ASPISR0.3
ARINT equ ASPISR0.4
ASPISR02 equ ASPID+1
ASPIID1 equ ASPID+2
ASRDY equ ASPIID1.0
ASERASE equ ASPIID1.1
ASPLAY equ ASPIID1.2
ASREC equ ASPIID1.3
ASPIID2 equ ASPID+3
;EXEC=inverted clock signal to SCK of ISD
;SDIN=(from ISD) MISO output fed through inverter
;DAT=(to ISD) MOSI input non-inverted
;R5 = # bytes to send into ISD
aspi:
mov R7,#8h ;Go through each byte
aspib:
setb EXEC ;set ISD clock to low
mov C,SDIN ;get bit from ISD
CPL C ;normalize input
mov A,#ASPIS ;Set start pointer
add A,R5 ;move pointer to end of data workspace
mov R0,A ;and let R0 be end of workspace
aspisb:
mov A,@R0 ;shift input R7 times through R5 bytes
rrc A ;ISD manual says LSB is first
mov @R0,A
dec R0
djnz R5,aspisb
mov DAT,C ;take LSB out of the whole thing and send it to ISD
clr EXEC ;and set clock to high
djnz R7,aspib
ret
what I throw at it without having to rewrite the same kind of lines over again
like in the first code?
I looked at page 31 of the guide for my chip found at http://www.microtechnica.tv/support/manual/ISD1700_Design_Guide.pdf and I don't know if my code is quite right.