??? 02/20/12 16:25 Modified: 02/20/12 16:31 Read: times |
#186064 - READ_SERIAL Responding to: ???'s previous message |
When you write the instruction..
JNB RI,$ .. it means "loop here forever until the RI bit becomes set". If that is the behavior that you expected then you are set. Single stepping the instruction would not advance until RI is advanced so the behavior you are getting would match your expectation. If you wanted some other behavior so that the program that called your READ_SERIAL didn't freeze up then you will have to add some more code. You could change the test of the RI bit so that READ_SERIAL routine returned some indication that a byte was read or not. One way would be to return the CARRY flag set if a byte is read and cleared if not. This way the caller to READ_SERIAL could do other work as well and calling READ_SERIAL periodically to see if a byte comes in. If in your debug process you have arranged for a byte to come to the UART such that the RI bit should be getting set from time to time and yet you still always freeze up at the JNB RI,$ then this could be indicative of any one of a number of errors or oversights in your program or hardware setup. These could be any one or more of: a) Is the UART initialized and the receiver enable bit set? b) Have you setup the UART with a valid baud rate clock? Input cannot be processed by the UART without a valid receiver side clock at 16X the desired baud rate. c) Is the header file that defines the RI bit specifying the correct bit address? Check against the data sheet for your MCU to make sure. d) Do you have the MCU internal peripheral logic configured properly to allow the RxD signal to make it from the designated pin to the onboard UART? As I see that you are using the SiLabs C8051F020 MCU this includes the proper initialization of the cross bar mechanism to allow the RxD signal from the pin to the UART. e) Have you verified that the received serial data signal actually arrives at the proper MCU pin? An oscilloscope is the tool of choice to check this. Michael Karas |
Topic | Author | Date |
Help. Writing Hex code from serial port to External device | 01/01/70 00:00 | |
Look at this | 01/01/70 00:00 | |
Using 8051 | 01/01/70 00:00 | |
Why ASM? | 01/01/70 00:00 | |
Design your subroutine(s) | 01/01/70 00:00 | |
RI Flag | 01/01/70 00:00 | |
READ_SERIAL | 01/01/70 00:00 | |
RI setup | 01/01/70 00:00 | |
are you sure? | 01/01/70 00:00 | |
CKCON | 01/01/70 00:00 | |
well, then | 01/01/70 00:00 | |
Correct | 01/01/70 00:00 | |
RI and TI | 01/01/70 00:00 | |
Ok | 01/01/70 00:00 | |
Diff Of TI and RI | 01/01/70 00:00 | |
Uart stall | 01/01/70 00:00 | |
Oscilloscope | 01/01/70 00:00 |