| ??? 12/23/09 14:52 Read: times |
#171889 - MAX3140 Responding to: ???'s previous message |
I'm bit-banging for the SPI. No problem here: I can successfully configure the MAX3140, read/write to all registers and I recieve the correct data from all registers. This tells me the Bit-Bang SPI code is working? Here's a snap shot.
;************************************************************************** ; Read/Write 16-bit Register MAX3140 ; ;************************************************************************** WRITE_MAX3140_16BIT_REGISTER: CLR CS_3140 MOV A,MAX3140_WRITE_REGISTER ;Get HB MOV R2,#8 SETB DIN_3140 ;make sure DIN is input HBYTE_3140: RLC A MOV DIN_3140,C ;Write SETB SCLK_3140 MOV C,DOUT_3140 ;Read CLR SCLK_3140 MOV ACC.0,C DJNZ R2,HBYTE_3140 MOV MAX3140_READ_REGISTER,A ; ;Get LByte ; MOV A,MAX3140_WRITE_REGISTER+1 MOV R2,#8 SETB DIN_3140 LBYTE_3140: RLC A MOV DIN_3140,C SETB SCLK_3140 MOV C,DOUT_3140 CLR SCLK_3140 MOV ACC.0,C DJNZ R2,LBYTE_3140 MOV MAX3140_READ_REGISTER+1,A SETB CS_3140 RET However, the more I dig into this, the more frustrated I get. As it turns out, if I "Delay" after sending each Character 'Tx' it works fine. However, I don't understand why if I read the cause of the IRQ from MAX3140 and Clear my TM (Transmit Registers) before writing a new character -why this does not work. I hate just putting in a "Dummy Delay" after each Character. Here's what I have. Again, this works! But it's not elegant and not quite right. I'm sure I am over-looking something in the data sheet or I have an error in my code.
CMD9: ;WRITE DATA Register to send Tx Character
;
MOV MAX3140_WRITE_REGISTER,#80H ;TE=0; RTS HIGH For Output
MOV MAX3140_WRITE_REGISTER+1,#02H ;Data to Tx 'STX'
LCALL WRITE_MAX3140_16BIT_REGISTER
;
JNB IRQ_3140, IRQ_1
IRQ_1: MOV R1,#200
LOOP1: NOP
NOP
DJNZ R1,LOOP1
;
|
| Topic | Author | Date |
| RS485 - MAX3140 | 01/01/70 00:00 | |
| SPI SOP | 01/01/70 00:00 | |
| MAX3140 | 01/01/70 00:00 | |
| I have: | 01/01/70 00:00 | |
MAX3140 - Solved | 01/01/70 00:00 |



