Skip to main content

SPI connecting two microcontrollers

     One of the things I wanted is connect and send data from a Master microcontroller to a Slave one via protocol SPI.

   



    To do so, I have programmed both microcontrollers with the programs named "spi_Master" and "spi_Slave" respectively.

    The master initiates the communication and transfers seven data gathered in an array called Dbuff[]. Each one has a different hexadecimal number which is transmitted through MOSI pin under the clock signal SCLK.

    The slave uses high level interrupt instead of waiting any data to be received; Once the SPIC_INT_vect is executed, the micro waits for the 0x53 as it indicates the beginning of the block. When this is received, the indexm variable is incremented saving all data into Dbuff[indexm] array.

    The hexadecimal number 0x53 prevents to read data in the middle of the block, always beginning at the same point or value.

Master program: spi_Master.c


Slave program: spi_Slave.c

Comments