how 2 intialize at89c51ed2 for spi communication with ds1306?
2 initialize datasheets.
Thank you for your reply sir. i have return this code. #include <REG51xD2.H> #include<stdio.h> #include<stdlib.h> unsigned char SPI(unsigned char);
void sdelay(int ); void main(void) { EA=1; SPSTA=0x00; SPCON=0xd6;
P1_7=1;//mOsi
P1_6=0;//sck P1_6=1; P1_1=1;//ss sdelay(1);
SPI(0x80); SPI(0x55); SPI(0x58); SPI(0x16); SPI(0x3); SPI(0x19); SPI(0x10); SPI(0x04); P1_1=0; sdelay(1); }
unsigned char SPI(unsigned char mybyte) {
SPDAT|=mybyte;
while(!(SPSTA&0x80)) { ; }
SPSTA&=0x00; return SPDAT;
}
void sdelay(int ms) { unsigned int i,j; for(i=0;i<ms;i++) for(j=0;j<135;j++);
here the value is not getting transmitted to SPDAT register.. I don't know what is the problem wiht this code
HI.
b4 u go on u must put a change in ur code to stop reset.
like;
void main(void) { . . . sdelay(1); for (;;) ; }
Always yo're freind.
Zeusti.
View all questions in Keil forum