| ??? 05/01/01 23:19 Read: times |
#11267 - RE: data movx problem |
Gerald:
The main reason your code isn't working, in my opinion, is that you are initializing SCON to 57h. You should initialize it to 52h. By initializing it to 57h you are also initializing RB8 (no reason to do that) and RI. The 8052 will never receive a serial character when RI is set. Thus by initializing SCON with RI set you are insuring that your program will never receive data. The following modified version of your program should work: ORG 0 SETUP: MOV TCON,#0C0h ; Load 1100 0000 MOV TMOD,#21h ; Load 0010 0001 MOV S0CON,#52 ; Load 0101 0010 MOV TH1,#0FDh ; 19,200 baud MOV DPTR,#0000h ;Initialize DPTR LOOP: JNB RI,LOOP ;Loop until a ser character is received MOV A,S0BUF ;Move data to A MOVX @DPTR,A ; move A to address 0x0000 INC DPTR ;increment data pointer SJMP LOOP ;Loop indefinitely, wait for next character END The main changes I made to your code were: 1. No reason to clear accumulator anywhere in the program. 2. Initializes SCON to 52h, not 57h (see above). 3. Removes CJNE instruction and replaced with SJMP. Your CJNE instruction created an infinite loop that can be just as easily achieved with the SJMP instruction. 4. Removes your SETB EA instruction. You weren't using interrupts anywhere so there's no reason to enable them. Good luck, Craig Steiner |
| Topic | Author | Date |
| data movx problem | 01/01/70 00:00 | |
| RE: data movx problem | 01/01/70 00:00 | |
| RE: data movx problem | 01/01/70 00:00 | |
| RE: data movx problem | 01/01/70 00:00 | |
RE: data movx problem | 01/01/70 00:00 |



