// Mikroc codes for SPI slave divice
// SIMULATION SUCCEED DSN IN My Doc PLATFORM FOLDER
void main()
{
unsigned int buffer, gdata =0;
trisa=0b00100000;
trisc=0b00011000;
trisd=0b00000000;
trisb=0b00000000;
INTCON.GIE = 1;
SSPSTAT.SMP=0;
SSPSTAT.CKE=0;
//SSPCON.SSPOV=0;
SSPCON.SSPEN=1;
SSPCON.CKP=1;
SSPCON.SSPM3=0;
SSPCON.SSPM2=1;
SSPCON.SSPM1=0;
SSPCON.SSPM0=0;
//Spi_Init_Advanced(SLAVE_SS_ENABLE,DATA_SAMPLE_END,CLK_Idle_HIGH,LOW_2_HIGH);
while(1)
{
if(SSPSTAT.BF)
{
gdata=SSPBUF;
SSPCON.SSPOV=0;
}
// gdata=Spi_Read(0);
if(gdata>100)
{
portb.f6=1;
portb.f7=0;
//delay_ms(20);
}
else
{
portb.f6=0;
portb.f7=1;
//delay_ms(20);
}
}
}