emSPI_I2CMasterSetup | Top Next

emSPI_I2CMasterSetup set up embedded Master SPI or I2C bus. Since R2019b Library: embeddedCreatorLib ( Dafulai Electronics) / Embedded SPI/I2C Bus Master / emSPI_I2CMasterSetup Description Set up embedded Master SPI or I2C bus. Let's introduce Our Master SPI/I2C access blocks. It is the same way as Master Modbus and CAN bus transmitting. The embedded Master SPI/I2C bus reading/writing operations are in Sequences. Total max Sequences quantity is 15 from Seq0 to Seq14. Small Sequence Number has higher priority for accessing. All sequences must be operated when bus is in Idle status. You can use block "isSPI_I2C_Idle" to know whether bus is in "Idle" status. Any Sequence operation will make bus busy (exit Idle status). When all Sequences done, you must set bus to "Idle" status in order to operate next time. You just use block "emSPI_I2CAllDone" to know whether all Sequences done. You just use block "setSPI_I2C2Idle" to set Bus in "Idle" status when all Sequences done. Notes: 1 You must set up I2C bus interrupt enable and SPI bus interrupt disable in MCU Configuration software such as MPLABX IDE MCC for Microchip technology MCUs. 2 In STM32CubeIDE/STM32CubeMx platform, you must enable interrupt for SPI/I2C. But you cannot enable DMA. 3 In TI C2000Ware /SysConfig platform, for I2C, you must enable interrupt, but for FIFO, don't care. Some F28Xs such as F28P65X do not work for "pure read" when FIFO enabled. please use "First write then read" to replace or just disable FIFO. For SPI bus, you can enable interrupt or enable DMA. 4 In TI C2000Ware/SysConfig platform,Peripheral 2/3/4 maybe SPIA or I2CA if you didn't add SPIB/SPIC/SPID or I2CB/I2CC/I2CD. For example , You use the 4th peripheral SPI, in general, it will use SPID because TI perrpheral naming in "A,B,C,D" order. However, our block found that SysConfig only added SPIB peripheral. And SPIB is not used by other emSPI_I2CMasterSetup blocks. No SPID found. Our block will use SPIB. Parameters Please double click this block to open parameters dialog below: When we choose Bus type to I2C bus from drop list, the dialog displays below: Let us explain parameters.
• | Peripheral Number — tell system which SPI/I2C controller peripheral is used. You just choose from drop list items: 1 to 4. It must match settings in your configuration software such as MCC for Microchip technology MCUs
• | bus type — tell system which bus is used. You just choose from drop list items: SPI bus and I2C bus.
• | SPI BUS communication width — This is SPI Bus Data width. You can choose 8 or 16. It is only for SPI bus, not for I2C bus. SPI bus's other settings like Pol/ Phase (Mode) are in your configuration software such as MCC for Microchip technology MCUs
• | Max bytes Qty for SPI bus access in one transaction — This is for SPI bus not I2C bus. We know that Actual transmitting data QTY including dummy data is equal to actual received data QTY including not interested received data. This parameter specifies the maximum of data QTY in byte unit in all transactions.
• | Max Sequence Qty for SPI or I2C — As its name, it is Max Sequence Qty, you just choose from drop list items from 1 to 15,
• | Max bytes Qty for I2C writing — It is only used for I2C bus. For one sequence of I2C operation, it can be First Writing and then reading in one transaction (One "start" signal, and then writing, and then "re-start " signal, and then reading, at last "stop" signal). It can be Writing only in one transaction (One "start" signal, and then writing, at last "stop" signal). It can be Reading only in one transaction (One "start" signal, and then reading, at last "stop" signal). This is Max byte Qty of writing in all sequences.
• | Max bytes Qty for I2C reading — It is only used for I2C bus. For one sequence of I2C operation, it can be First Writing and then reading in one transaction (One "start" signal, and then writing, and then "re-start " signal, and then reading, at last "stop" signal). It can be Writing only in one transaction (One "start" signal, and then writing, at last "stop" signal). It can be Reading only in one transaction (One "start" signal, and then reading, at last "stop" signal). This is Max byte Qty of reading in all sequences.
Ports Input None Outport None Examples