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 problem in P89v51RD2

Status
Not open for further replies.

moni_

Newbie level 3
Joined
Mar 28, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
i have interfaced two p89v51rd2 micro-controllers configuring one as master and another as slave.
but i'm not getting any data and spi data transfer is not taking place. i used cro to check the spi clock signal but i'm just getting 5v dc signal. dont know what is the problem.
please anyone check whether my code is correct... i have doubt in slave configuration.

the interfacing is shown in below figure:
https://obrazki.elektroda.pl/62_1332911780.png

code for master:


Code C - [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
#include "p89v51rx2.h"*** ** 
#include <INTRINS.H> 
sbit*** SS= P1^4; 
sbit*** spiclk = P1^7; 
sbit*** MOS1 = P1^5; 
sbit miso = P1^6; 
sbit**** st = P2^1; 
sbit*** irq = P2^0; 
char xacc1,xacc2; 
unsigned int i=0; 
*
void msdelay( unsigned int); 
void serial (); 
*
void main() 
{ 
** 
* SS = 1; 
* irq = 1; 
* SPCTL = 0xdf; 
* SPCFG = 0X00; 
* P1 = 0x40; 
* ES0 = 1; 
*
*while (1) 
* { 
*** SPDATA = 0X11; 
*** while (!(SPCFG & 0x80)); 
*** SPCFG = 0X00; 
*** serial (); *** 
** } 
}*** 
*
*void msdelay(unsigned int ms) 
{ 
unsigned int i,j; 
for (i=0;i<ms;i++)** 
for (j=0;j<53;j++); 
} 
*
void serial () 
*{ 
*
*while (1) 
* { 
** TMOD = 0x20; 
** TH1 = 0xfd; 
** SCON = 0x50; 
 
** TR1 = 1; 
** TI = 0; 
** SBUF = xacc1; 
** while (!TI); 
** TI = 0; 
*
** TR1 = 1; 
** SBUF = xacc2; 
** while (!TI); 
** TI = 0; 
* }



code for slave:


Code C - [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
#include "p89v51rx2.h" 
#include <INTRINS.H> 
sbit*** SS= P1^4; 
sbit*** spiclk = P1^7; 
sbit*** MOS1 = P1^5; 
sbit*** MISO = P1^6; 
sbit*** irq = P2^0; 
*
*unsigned int i=0; 
*
void main() 
{ 
* SPCFG = 0X00; 
* SPCTL = 0xcd; 
* P1 = 0xc0; 
* SS = 0; 
* ES0 = 1; 
*
* irq = 0; 
* while (!(SPDATA == 0X11)); 
**** SPDATA = 0x4E; 
*** *for(i=0;i<10;i++);* 
*
** while (!(SPDATA == 0X22)); 
**** SPDATA = 0x52; 
* *** *for(i=0;i<10;i++); 
*}


please tell me what is the problem with the code... thank u
 
Last edited by a moderator:

Hai moni..

Please interchange the MISO and MOSI in slave or master. your picture shows correct information but in your port pin config it is wrong.

If still it didnt work, let us go through the code

thanks and regards
karthikkr
 

Hi Mr. karthik,
But we are not using that port pin MOSI and MISO anywhere in the code. even if i change, it does not make any difference right? please go through the code once..
 

Hi Mr. karthik,
But we are not using that port pin MOSI and MISO anywhere in the code. even if i change, it does not make any difference right? please go through the code once..


Hi Moni,

Please specify the problem again in detail with the Port pins used (before that check the pins on board & defined in the code).

We shall check the code later.

Mahesh V S
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top