??? 06/09/04 20:23 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#72215 - RE: 4Bit to serial (Tx/Rx) Responding to: ???'s previous message |
hi,
there are alot of comments I am filled. Just read them, maybe something helps. some optimization: - MOV A, PCON ;setting SMOD = 1, Read-Modify-Write SETB ACC.7 ; MOV PCON, A ; may be replaced with ORL PCON,#10000000b- RL A RL A RL A RL A may be replaced with SWAP ANow here are another notes: - I recommend you to save/restore not only ACC but PSW as well during ISR. It is "good programming" way. - as for now, I see at least one error you did: due SCON initialization, you do MOV SCON,#52H. If you look at description of SCON bits then you may see that with this command you have set TI bit. But some lines below you have: MOV SBUF, #00000000B ;send start byte JNB TI, $Because TI is already set, your program passes through this condition. And even here it does not make malfunction. But here: ORL A, TxBuffStart JNB TI, $ ;loop until transmittor is ready CLR TI MOV SBUF, A it has a chance of failure. Think yourself: - you send start byte and wait till it comes out with looking at TI. But TI is already set during SCON initialization and so there is no wait loop here. Now in transmission section there is a condition to send data: it waits for TI and then send a byte. Ooops, TI has been already set and so it loads UART with new byte at time when previous (start) byte is sending! So SBUF is overloaded and result is not defined. What I suggest: 1) use 0x50 for SCON initialization. 2) do not allow any interrupts before start byte has been sent (here: move line MOV IE,#10010001B down before the line JMP $). Regards, Oleg |
Topic | Author | Date |
4Bit to serial (Tx/Rx) | 01/01/70 00:00 | |
RE: 4Bit to serial (Tx/Rx) | 01/01/70 00:00 | |
RE: 4Bit to serial (Tx/Rx) | 01/01/70 00:00 | |
RE: 4Bit to serial (Tx/Rx)![]() | 01/01/70 00:00 |