moni_
Newbie level 3
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 for slave:
please tell me what is the problem with the code... thank u
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: