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.

project on spi using at89s8252.......

Status
Not open for further replies.

prabhu.embedded

Member level 1
Joined
Feb 14, 2012
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,562
hlo sir,
i m doing a project on spi using at89s8252.actually i want to know about it briefly,with ckt dig & referance code.
plz sir its urgent.


thnq u sir.
 

what is your project about? explain more to help you in proper way
 

hlo sir,
actually i want to know the spi protocol,normaly project on sending data throw mcu 8051.affter sending how will it work at other mcu..tell me?plz give a reference code for refer and gain knowledge to doing this project..........


thnk u ..

---------- Post added at 05:27 ---------- Previous post was at 05:23 ----------

hlo sir,
actually i want to know the spi protocol,normaly project on sending data throw mcu 8051.affter sending how will it work at other mcu..tell me?plz give a reference code for refer and gain knowledge to doing this project..........


thnk u ..
 

actually i want to know the spi protocol,normaly project on sending data throw mcu 8051.affter sending how will it work at other mcu..tell me?plz give a reference code for refer and gain knowledge to doing this project..........

from your reply i don't understand much but i guess you want to use master slave communication if yes then you need use RX/ TX pin of both controller. if you want do send data to other controller. if you want to do send data some other device like EEPROMS, External ADC or any other device whos working on SPI protocol then you need bascially 3 pins for handshaking that pins name MOSI(master out slave in),MISO(master in slave out),SCLK(serial clock) these are main to communicate on SPI protocol.

https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
refer this link for more detail on SPI
 

hlo sir,
plz tell me the spi hardware connection with at89s8252 with ckt diagaram..its urgent
 

give us your schematic diagram or work you have done till now. you are not mentioning about your spi device clearly
 

hlo sir,
i want to connect AT25C040 with at89s8252.so have you any ckt dig. plz give me.
 

hlo sir,
thx for telling me.but 1 another reply give that how i connect spi throw to microcontroller that at 89s8252.plz give me the ckt diagram.


thnk u ..
 

EEPROM connection to controller is there in datasheet what else you want you want to use two micro controller?

see attachment that should be your circuit diagram

What do you mean bye SPI throw??
 

Attachments

  • spi.JPG
    spi.JPG
    55.8 KB · Views: 90
Last edited:

hlo sir
i want to know that how i connect dac MCP4291 with mcu at89s8252.give me ckt dig.
 

it should be like this you can connect any three pins of at89s8252 for e.g. say P2.0 is sclk,p2.1 is cs and so on this way you can connect .
 

Attachments

  • spi2.JPG
    spi2.JPG
    45.9 KB · Views: 92

i have four pins like cs,sck ,miso,mosi ,so i connect these four pins to dac.can i connect it randomly.

---------- Post added at 10:08 ---------- Previous post was at 10:02 ----------

hlo sir,
any surce code for it plz give for refer.
 

ya you can connect randomly but you should build desire calk pules (using software)at clock pin to communicate properly with device

i don't have any reference code now but you can find it many on Google
 

sir
plz give the proper address to find it..if you geting any code plz give me.

---------- Post added at 10:23 ---------- Previous post was at 10:17 ----------

i want the assembly code.plz give me is..plz urgent.

---------- Post added at 10:35 ---------- Previous post was at 10:23 ----------


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
;******************************************************************************************************
;*****************************************************************************************************
SPCR DATA 0d5h ; SPI control register
SPSR DATA 0aah ; SPI status register
SPIF EQU 10000000b ; interrupt flag
SPDR DATA 86h ; SPI data register
DATAa  equ 0a0h
ADDRESS EQU 40
;***********************************************************************************************
;***********************************************************************************************
; Microcontroller connections to dac
CS_ BIT p3.0 ; 
MOSI BIT p3.1 ; SPI
MISO BIT p1.2 ; SPI
SCK BIT p3.3 ; SPI
; AT25040 device command and bit definitions.
RDSR EQU 05h ; Read Status Register
WRSR EQU 01h ; Write Status Register
READ EQU 03h ; Read Data from Memory
WRITE EQU 02h ; Write Data to Memory
WREN EQU 06h ; Write Enable
WRDI EQU 04h ; Write Disable
A8 BIT acc.3 ; MSB of address
NRDY BIT acc.0 ; high = write cycle in progress
;************************************************************************************
;*************************************************************************************
main:
; SPI master mode initialization code.
setb CS_ ;
setb MOSI ; initialize SPI pins
setb MISO ;
setb SCK ;
mov SPCR, #01010101b ; initialize SPI master
;******************************************************************************************
;*****************************************************************************************
; interrupt disable, pin enable,
; MSB first, polarity 0, phase 1,
; clock rate /16
; Write one byte to dac and verify (read and compare).
; Code to handle verification failure is not shown.
; Needs timeout to prevent write error from causing an infinite loop.
call enable_write ; must precede each byte write
mov a, #DATAa ; data
mov dptr, #ADDRESS ; address
call write_byte ; write
wchk:
call read_status ; check write status
jb NRDY, wchk ; loop until done
mov dptr, #ADDRESS ; address
call read_byte ; read
cjne a, #DATAa, ERROR ; jump if data compare fails
error:
sjmp main
read_status:
; Read device status.
; Returns status byte in A.
clr CS_ ; select device
mov a, #RDSR ; get command
call masterIO ; send command
call masterIO ; get statussetb CS_ ; deselect device
ret
enable_write:
; Enable write.
; Does not check for device ready before sending command.
; Returns nothing. Destroys A.
clr CS_ ; select device
mov a, #WREN ; get command
call masterIO ; send command
setb CS_ ; deselect device
ret
read_byte:
; Read one byte of data from specified address.
; Does not check for device ready before sending command.
; Called with address in DPTR.
; Returns data in A.
clr CS_ ; select device
mov a, dph ; get high byte of address
rrc a ; move LSB into carry bit
mov a, #READ ; get command
mov A8, c ; combine command and high bit of addr
call masterIO ; send command and high bit of address
mov a, dpl ; get low byte of address
call masterIO ; send low byte of address
call masterIO ; get data
setb CS_ ; deselect device
ret
;**************************************************************************************************
;**************************************************************************************************
write_byte:
; Write one byte of data to specified address.
; Does not check for device ready or write enabled before sending
; command. Does not wait for write cycle to complete before returning.
; Called with address in DPTR, data in A.
; Returns nothing.
clr CS_ ; select device
push acc ; save data
mov a, dph ; get high byte of address
rrc a ; move LSB into carry bit
mov a, #WRITE ; get command
mov A8, c ; combine command and high bit of address
call masterIO ; send command and high bit of address
mov a, dpl ; get low byte of address
 
call masterIO ; send low byte of address
pop acc ; restore data
call masterIO ; send data
setb CS_ ; deselect device
ret
;**************************************************************************************************
;************************************************************************************************
masterIO:
; Send/receive data through the SPI port.
; A byte is shifted in as a byte is shifted out,
; receiving and sending simultaneously.
; Waits for shift out/in complete before returning.
; Expects slave already selected.
; Called with data to send in A. Returns data received in A.
mov SPDR, a ; write output data
bbb:
mov a, SPSR ; get status
anl a, #SPIF ; check for done
jz bbb ; loop until done
mov a, SPDR ; read input data
ret
end

 
Last edited by a moderator:

sir
accoding to my development boad spi connection is throw dac MCP4291. SPI DAC - P3.0 ( CS), P3.1(SCK) and P3.2(SDI) to make switch SW32 ON for SPI DAC Selection.
so i want to know one another pin sdo ,,how i will use in program........


thnk q
 

if you are using development board then what a waste of time for asking circuit diagram. that seem you are not here to learn something.
 

halo sir,
thx for advice me.but do you pl z help me to say that how spi works in ADC mcp3202 using at89s8252 m cu.pl z tell me that briefly.great full to u............


thank u
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top