SX48DB: Port Write Error
Hello there!
I am now developing some product using two SX48ProtoBoards(with SX-Keys) which communicate with each other through RE port.
But the value I try to write in RE port connected to the other SX48·is· written differently in the register sometimes ,not always in SX-Key's Debug-Run mode.
In other words, different value is written.
The source code is as follows:
;////////////////////////////
; Transmit byte data
;////////////////////////////
:transmit_next_byte
··mov·W,#$1F···;Mode=Directopn
··mov·M,W
··;mov·· ·RE,#%0000_0000········ ·;must specify port before dir set
··mov···· !RE,#RW_bus_ta_TX_DIR·;transmit mode dir.
; tx upper nibble
··mov·RW_temp,RW_read_val
··and·RW_temp,#%1111_0000
··clc
··rr·RW_temp···;rotate right * 4
··rr·RW_temp
··rr·RW_temp
··rr·RW_temp
··mov·RW_tx_upper_nibble_log,RW_temp
··mov·W,RE
··and·W,#%1111_0000··;mask the lower nibble
··or·W,RW_temp
··mov·RE,W···;transmit upper nibble
··nop····;REV097Gz1e
··mov·RW_tx_upper_nibble_phy,RE
;
··nop····;read-modify-write consideration?
··nop
··nop
;
··setb·RW_STRB_to_mx_pin·;RW_STRB:the Target
> Master
For example, though W value before 'mov RE,W' is $0A, RE value after the execution of the instruction is $08.
I·don't know this problem is related with· "Read-Modify-Write Considerations" in the data sheet.
But·can you explain more details about it?
Cranehill
JAPAN
·
I am now developing some product using two SX48ProtoBoards(with SX-Keys) which communicate with each other through RE port.
But the value I try to write in RE port connected to the other SX48·is· written differently in the register sometimes ,not always in SX-Key's Debug-Run mode.
In other words, different value is written.
The source code is as follows:
;////////////////////////////
; Transmit byte data
;////////////////////////////
:transmit_next_byte
··mov·W,#$1F···;Mode=Directopn
··mov·M,W
··;mov·· ·RE,#%0000_0000········ ·;must specify port before dir set
··mov···· !RE,#RW_bus_ta_TX_DIR·;transmit mode dir.
; tx upper nibble
··mov·RW_temp,RW_read_val
··and·RW_temp,#%1111_0000
··clc
··rr·RW_temp···;rotate right * 4
··rr·RW_temp
··rr·RW_temp
··rr·RW_temp
··mov·RW_tx_upper_nibble_log,RW_temp
··mov·W,RE
··and·W,#%1111_0000··;mask the lower nibble
··or·W,RW_temp
··mov·RE,W···;transmit upper nibble
··nop····;REV097Gz1e
··mov·RW_tx_upper_nibble_phy,RE
;
··nop····;read-modify-write consideration?
··nop
··nop
;
··setb·RW_STRB_to_mx_pin·;RW_STRB:the Target
> Master
For example, though W value before 'mov RE,W' is $0A, RE value after the execution of the instruction is $08.
I·don't know this problem is related with· "Read-Modify-Write Considerations" in the data sheet.
But·can you explain more details about it?
Cranehill
JAPAN
·
Comments
In the code you are modifing the lower nibble. So if the RW_read_val high nibble is different then what is currently on the low nibble or RE then it will change.
So if RW_read_val = $8x (x=don't care) then RE would change from $0A to $08 after the MOV RE,W instruction.
Watch what W is doing between the MOV W,RE and the MOV RE,W that should tell you if it is working correctly.
Read-Modify-Write problem usually occur when you have two consecutive instructions that use the same port, I don't see any in your code. You have a NOP between the MOV RE,W and MOV RW_tx_upper_nibble_phy so that is good.
P.S. You can just use SWAP instead of the CLC and four rotates.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
I give you more detail.
RW_tx_upper_nibble_log·=·reg_B0
RW_tx_lower_nibble_log·=·reg_B1
RW_rx_upper_nibble_log·=·reg_B2
RW_rx_lower_nibble_log·=·reg_B3
RW_tx_upper_nibble_phy·=·reg_B4
RW_tx_lower_nibble_phy·=·reg_B5
RW_rx_upper_nibble_phy·=·reg_B6
RW_rx_lower_nibble_phy·=·reg_B7
RW_arg_cnt··=·reg_B8
RW_arg_ptr··=·reg_B9
RW_arg1···=·reg_BA
RW_arg2···=·reg_BB
RW_arg3···=·reg_BC
RW_read_val··=·reg_BD
RW_temp···=·reg_BE
RW_session_cnt··=·reg_BF
The value of RW_read_val is $AB.
Please see the attached file which includes a snap shot of SX-Key Debugger.
Cranehill
[font=ï¼*ï¼³ ã´ã·ãã¯]·[/font]
If you could post the complete program I could maybe see something that would help.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
All·source codes are attached.
I really appreciate your help!
Crane hill
Try to make the simplest shortest program that demonstrates the problem.
I see you are running at 50MHz, and Read-Modify-Write problems do occur at this speed. I would examine any code that uses the same port that is not seperated by at least a couple instructions.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·
I extracted the code areas that might be causing the problem.
Please see·the·extraced source codes attached.
Cranehill