Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Reading Problem CS5460A

Status
Not open for further replies.

Kumar_373

Junior Member level 1
Junior Member level 1
Joined
Nov 22, 2003
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
158
cs5460a

Hi
I am doing a project on Energy meter Using CS5460A interfaced to microcontroller 89S52.

Connection detials
cs5460a 89S52
pin5(sclk) P1.1
pin6(sdo) P3.5
pin23(sdi) P1.2
pin7(CS) GND

I am using 20Mhz crystal for microcontroller and 4.Mhz for cs5460a I am not able to read from CS5460a.

can any tell me what could be the problem. how do i read the data.

Regards
Kumar
 

cs5460a code

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
 
Last edited by a moderator:
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
 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top