cs5460a
Dear Ianp
The following the routine for read and write to cs5460a
void write_to_register(char command,char low,char mid,char high)
{
transfer_byte(command);
transfer_byte(high);
transfer_byte(mid);
transfer_byte(low);
}
void read_register(char command)
{
transfer_byte(command);
high_byte = receive_byte(); /*Receive Bytes*/
mid_byte = receive_byte();
low_byte = receive_byte();
}
NAME TRANSFER_BYTE
?PR?_transfer_byte?TRANSFER_BYTE SEGMENT CODE
PUBLIC _transfer_byte
RSEG ?PR?_transfer_byte?TRANSFER_BYTE
_transfer_byte:
USING 0
MOV A, R7 ; Move byte to be transmitted to ACC
MOV R1,#08 ; Set count to 8 to transmit byte
CLR P1.1 ; Clear SCLK( old data P1.3)
loop: ; Send Byte
RLC A ; Rotate Accumulator, send MSB 1st
MOV P1.2,C ; Transmit MSB first through C bit
SETB P1.1 ; Set SCLK (old data P1.3)
CLR P1.1 ; Clear SCLK
DJNZ R1,loop ; Decrement byte, repeat loop if not zero
SETB P1.2 ; Reset SDI to one when not transmitting( old data P1.3)
RET ; Exit subroutine
END ; END OF _transfer_byte
NAME RECEIVE_BYTE
?PR?_receive_byte?RECEIVE_BYTE SEGMENT CODE
PUBLIC _receive_byte
RSEG ?PR?_receive_byte?RECEIVE_BYTE
_receive_byte:
USING 0
MOV R1,#08 ; Set count to 8 to receive byte
SETB P1.1 ; Set SDI when not in use
LOOP: ; Receive the byte
MOV C,P3.5 ; Move bit to carry ( old data P1.2)
RLC A ; Rotate A in preparation for next bit
SETB P1.1 ; Set SCLK ( old data P1.3)
CLR P1.1 ; Clear SCLK
DJNZ R1,LOOP ; Decrement byte, repeat loop if not zero
MOV R7,A ; Byte to be returned is placed in R7
RET ; Exit subroutine
; END OF _receive_byte
END
I have initializated the serial port using sync1(0xff) and sync0(oxfe) but still i am not able to read can tell me what could be the problem.
Thanks
IanP said:
There can be many possible reasons why you couldn't establish communication between the 89S52 and the CS5460 ..
Assuming that the CS5460 hardware connection is correct and the CS5460 is properly powered, do you use the right write/read timing?
Have you started with serial port initialization?
(see P18 of: **broken link removed** )
Regards,
IanP