SPI not working with connecting two PIC16F877

Thread Starter

icem

Joined Nov 15, 2009
26
hi

Im trying to send an byte of data via spi between two PIC16f877.

I have set one chip as master and other as slave.

Is there a way to find out if the spi is actually sending data?

My master chip takes inputs from an accelerometer and computes an value corresponding to the angle a which it is at.

What i'm trying to do is send that value to another PIC which will output the value onto an LED display.

Any help would be great

Thank you very much for your time.
 

Thread Starter

icem

Joined Nov 15, 2009
26
I'm just I realise that the code for the master is quite long so here is the important bits,

Rich (BB code):
  setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_4);
Rich (BB code):
         if (((DutyCycleX >=0)&&(DutyCycleX  <= 220))|((DutyCycleX  >265)&&(DutyCycleX  <= 285)))
         {
            lightsX = 0x18;
         }
         else if (((DutyCycleX  >220)&&(DutyCycleX  <= 265)))
         {
            lightsX = 0x40;
         }
         else if (((DutyCycleX  >285)&&(DutyCycleX  <= 320)))
         {
            lightsX = 0x40;
         }
          else if (((DutyCycleX  >320)&&(DutyCycleX  <= 380)))
         {
            lightsX = 0x0f;
         }
         else if (((DutyCycleX  >380)&&(DutyCycleX  <= 1000)))
         {
            lightsX = 0x0f;
         }
         printf("\r\n lightX = %d",lightsX );
         spi_write(lightsX);
         delay_us(100); 
         value = spi_read();
Thank you
 

ahmed899

Joined Apr 8, 2011
1
i need a basic spi code to test whether spi is working or not. I am using C18 compiler. I want to establish a simple communication between 2 pic18f452, one as a master and other as a slave..!!

Please help me out or guide to some resources from where i could eslily manage!!

thanks
 
Top