---------------------------------------------------------

//This fragment reads incoming frame from the CS8900A

//Call from C as read_frame(UINT xdata * buf, UINT len)

//R6, R7 point to buf and length is in R4, R5

---------------------------------------------------------

RSEG ?PR?_READ_FRAME?CS8900

_READ_FRAME:

MOV DPL, R7 //Set up data pointer

MOV DPH, R6

LOOP:

MOV P1, #018H //Take CS8900A CS low, set address

CLR P1.3 //Take CS8900A RD strobe low

NOP //Allow for CS8900A access time

NOP //Each NOP is 45 ns at 22.1184 MHz

NOP

MOV A, P2 //Read low byte into port 2

MOVX @DPTR, A

INC DPTR

MOV A, P3 //Read high byte into port 3

MOVX @DPTR, A

INC DPTR //Advance data pointer

MOV P1, #038H //Take RD strobe, chip select high

DJNZ R5, LOOP //Decrement, loop again if needed

DJNZ R4, LOOP

RET