Hi all
I am trying to communicate two 16f877a PICs via SPI. But there is a problem. Simply the master write integer 3 into Slave, slave read it and check that value is greater than int 7. If Yes it blink 2 LEDs on RB6 and RB7, else RB6 LED is on.
two codes work correctly on PROTEUS simulator. But in real arrangement, If I send value larger than 7 it blink correctly and some times when I powered two microcontrollers it flash only RB6 as well. Please help me to find where the mistake.
I used MikroC compiler. Default Spi_init() initiate followings.
Default settings are: Master mode, clock Fosc/4, clock idle state low, data transmitted on low to high edge, and input data sampled at the middle of interval.
Thank you btbass!
But still problem remains. Now I'm going to do this without inbuilt functions. and try to do this manually. I'll come with my results soon. And I want to know how can I add Helpful icon.
Thank you again.
---------- Post added at 20:38 ---------- Previous post was at 18:41 ----------
// code for spi master
void main()
{
trisc.f3=0; // Clock out from master
trisc.f4=1; // Data in From slave
trisc.f5=0; // Data out To slave
//trisa.f2=0;
//porta.f2=1;
//delay_ms(10);
//porta.f2=0;
Spi_Init();
while(1)
{
Spi_Write(2);
}
}
change your oscillator configuration in your ide to HS oscillator. If you are burning your code in a universal programmer like topwin,select HS oscillator in the configuration bits there also.since you are using a 20Mhz oscillator,set your sspcon register in Fosc/16. It will work
thank you, I' ll try and post my results, but I have exams in these two weeks. As soon as possible I will change my configuration, my burner software is picpgm.
thank you