Ram Prasadh
Member level 2
- Joined
- Feb 16, 2011
- Messages
- 51
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 1,288
- Activity points
- 1,725
I am new in using SPI. I am interfacing a MAXQ3180 and PIC16F72(master). Can you please tell me whether I am checking the SSPIF and the BF correctly. I am sending 0x00 and expecting 0xc1 from the max.But I am not able to get it. My SDO,SDI,SCK,RC1(reset pin to max) pin are in logic high after connecting with max. I am using a 12Mhz crystall oscillator to the pic and 8Mhz crystall in max. It is stated in the Max data sheet that"the SPI clock frequency used by the master must be less than or equal to the MAXQ3180’s clock frequency divided by 8. For example, when the MAXQ3180 is running at 8MHz, the SPI clock frequency must be 1MHz or less for proper communications operation". Here in pic , my 12 Mhz will get divided by 16,I am getting 750 Khz nearly for the SPI clock.Is there anything other than this I have to do? what may be the problem?
void main()
{
ADCON1=6;
TRISA=0X00;
TRISB=0X00;
TRISC=0X10;
INTCON=0x40; //only peripheral interrupt is enabled
PIE1=0x08; //SSPIE is enabled
SSPIF=0;
SSPCON=0b00110001; //SSPEN=1 CKP=1;
SSPSTAT=0b11000000;
RC1=0; RC1=1; // RESET pin
write_enable();
}
void write_enable()
{
RA5=0; //Slave Select Pin
SSPIF=0;
SSPBUF=0X00;
while(SSPIF==0); SSPIF=0; //transmit
delay_50uS();
while(SSPIF==0 && BF==0);SSPIF=0; //recieve
if(SSPBUF==0XC1)
RB7=1;
else
RB6=1;
RA5=1; //SPI over
for(;;
}
PS* I dont have a logic analyzer and cannot afford one. I am burning the hex and using it.
void main()
{
ADCON1=6;
TRISA=0X00;
TRISB=0X00;
TRISC=0X10;
INTCON=0x40; //only peripheral interrupt is enabled
PIE1=0x08; //SSPIE is enabled
SSPIF=0;
SSPCON=0b00110001; //SSPEN=1 CKP=1;
SSPSTAT=0b11000000;
RC1=0; RC1=1; // RESET pin
write_enable();
}
void write_enable()
{
RA5=0; //Slave Select Pin
SSPIF=0;
SSPBUF=0X00;
while(SSPIF==0); SSPIF=0; //transmit
delay_50uS();
while(SSPIF==0 && BF==0);SSPIF=0; //recieve
if(SSPBUF==0XC1)
RB7=1;
else
RB6=1;
RA5=1; //SPI over
for(;;
}
PS* I dont have a logic analyzer and cannot afford one. I am burning the hex and using it.