SPI.setBitOrder(MSBFIRST) //bit transmission order SPI.begin() //PB2 - PB4 are converted to SS/(OUT-H), MOSI(OUT-L), MISO(IN), SCK(OUT-L) Send one byte data (0x23) from the Master-UNO receive it by Slave-MEGA and show on Serial Moniotr. It is used to know the readiness of data. There are 3 Registers inside SPI Interface: The Slave, if wishes, can use the interrupt strategy to know the readiness of data in the SPDR register. When SPIF bit found LH, the Slave reads the data from SPDR Register and keeps it in a variable. The Slave knows it by continuously monitoring the SPIF flag bit of the SPSR Register. The Master can continuously monitor this flag bit (SPIF) to determine that data transmission is complete it can now initiate the transmission of next data byte.Īt the Slave side, the Slave waits until all data bit have arrived in its SPDR Register. At the end of complete shift of all the data bits, the SPIF bit assumes LH (HIGH) state. When the Master begins to shift out data, the SPIF-bit (SPI Flag bit) of SPSR Register becomes LOW, and it remains LOW until all the data bits have been shifted out. The present content of the Slave-SPDR Register also shifted out bit-by-bit and enters into Master-SPDR Register. A data byte is shifted out bit-by-bit from Master-SPDR Register response to SCK the shifted bits also enter bit-by-bit into the Slave-SPDR Register. The above diagram indicates that the SPI is a Circular Buffer System. My preferred connection between UNO (Master) and MEGA (Slave) The correspondences among these signals and the DPins are:ģ. The SPI signals are clearly indicated except the SS/-signal which we will be used to select the SLave (the MEGA). The Pin-out diagram of the ICSP Connector of UNO is: The correspondences among these signals and the DPins are:Ģ. The SPI signals are clearly indicated except the SS/-signal which we need for the MEGA to be selected as Slave by the UNO. The Pin-out diagram of the ICSP Connector of MEGA is:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |