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.

Spi interfacing with ade77xx

Status
Not open for further replies.

benag6

Newbie level 4
Joined
Mar 24, 2004
Messages
7
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
90
ade77xx

Hi friends,

I have two doubts regarding

1.interfacing external eeprom interfacing.

If ext.eeprom (for eg AT24c04) is directly connected to atmega16 with correct 10k pull up resistor, I am not getting the proper channel set for data flow and hence data transfer doesn't takes place but when i changed volatge from Vcc(5v) to 3.3v it worked.why?


2. I have the below subroutine to know the spi working.
Below is a subroutine part of 4-wire interface:
It is not working. Can anyone find any faults in it. I also like to know about any precise volatge values has to be given at din and dout pin.

suggest me ideas, view.

nakkeeran




//program to know the working of data transfer using SPI.

.include "m16def.inc"

.def temp = r16
.def temp1 = r17
.def data = r19
.equ sclk = 7 ;PB7 pin
.equ cs = 4 ;PB4 pin
.equ mosi = 5 ;PB5 pin
.equ miso = 6 ;PB6 pin

.cseg
.org $0


jmp reset
reti

reset:

ldi temp1,low(ramend)
out spl,temp1 ;set lowbyte for sp
ldi temp1,high(ramend)
out sph,temp1 ;set highbyte for sp
ldi temp,0xff;
out DDRC,temp
out DDRA,temp
out DDRD,temp

checkingSPI:
init_spi:

ldi temp,0xb0;direction settings in portB.
out DDRB,temp;
ldi temp,0x70;initial port pulses as high
out portb,temp;
ldi temp,$55;control reg is set for falling edges. hence cpha=1.
out spcr,temp

writecmd_spi:
ldi data,$8a;this is the address where data has to be stored,also bit 7 is for write enable.
cbi portb,4;cs=low

out spdr,data
intrpflag:
sbis spsr,spif
rjmp intrpflag
call w_16ms

writedata_spi:

cbi PORTB,4
ldi data,$33 ; this is data
out spdr,data
getintrpflag:
sbis spsr,spif
rjmp getintrpflag
sbi PORTB,4;//set bit chipselect

readcmd_spi:; this is the reading data routine.

ldi data,$0a;this is data reading address,here 0 at bit 7 is read enable.
cbi portb,4
out spdr,data
getintrflag:
sbis spsr,spif
rjmp getintrflag
call w_16ms

read_data_spi:
cbi PORTB,4
ldi data,$51;some rough value.
out spdr,data
getintr4:
sbis spsr,spif
rjmp getintr4
in data,spdr
out portd,data; displaying the data here it shd be $33.

rep:rjmp rep
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top