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

 

 

emSPI_I2CSetup

 

 


 

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: 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.

 

Parameters


 

Please double click this block to open parameters dialog below:

 

emSPI_I2CSetup_param1

 

 

When we choose Bus type to I2C bus from drop list, the dialog displays below:

 

emSPI_I2CSetup_param2

 

 

 

 

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