Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
By
Sasi Kumar C
Development Engineer
Why? Æ SPI
¾ Data synchronization
What? Æ SPI
¾ The SPI protocol uses four wires to carry out the task of data
communication:
9 MOSI: master out slave in
9 MISO: master in slave out
9 SCK: serial clock
9 SS: slave select
¾ An SPI data transfer is initiated by the master device.
¾ The SPI protocol is mainly used to interface with MCU’s, shift registers,
LED/LCD drivers, phase locked loop chips, memory components with SPI
interface, or A/D or D/A converter chips.
Master Mode
¾ Master mode allows the DSPI to initiate and control serial communication.
¾ In this mode the SCK, PCSn and SOUT signals are controlled by the DSPI and
configured as outputs.
Slave Mode
¾ Slave mode allows the DSPI to communicate with SPI/DSI bus masters.
¾ In this mode the DSPI responds to externally controlled serial transfers. The DSPI
cannot initiate serial transfers in slave mode.
¾ In slave mode, the SCK signal and the PCS0/SS signal are configured as inputs.
Signal Properties
The DSI configuration supports pin count reduction by serializing parallel input signals
or register bits and shifting them out in an SPI-like protocol.
The received serial frames are converted to a parallel form (deserialized) and placed
on the parallel output signals or in a register.
Up to 16 ETPU (or a combination of eTPU and eMIOS ) channels can be serialized onto 3
wires (half-duplex master transmit) or 4 wires for master/slave operation.
Data is taken from the eTPU, eMIOS, or ASDR and transmitted serially.
Data from a received SPI frame is routed through to the eTPU, eMIOS channels, or to the
SIU interrupts.
The Combined Serial Interface (CSI) mode allows the DSPI to operate in both SPI and DSI
configuration.
In master mode, the CSI configuration of the DSPI is used to support SPI and DSI functions
on a frame by frame basis.
CSI configuration allows interleaving of DSI data frames from the parallel input signals (from
the eTPU or eMIOS) with SPI commands and data from the TX FIFO.
The data returned from the bus slave is either used to drive the parallel output signals (to
the eTPU or eMIOS) or is stored in the RX FIFO.
CSI DeSerialization
¾ Data transfers serially using shift registers. SPI frames can be 4 to 16 bits long. It
supports two module specific modes – Master , Slave.
¾ Master Mode initiates and controls the transfer according to command field
¾ Slave Mode only responds to the Master mode
The MPC5553/MPC5554 DSPI modules each contain eight clock and transfer attribute
registers (DSPIx_CTARn) which are used to define different transfer attribute configurations.
Like • Frame size
• Baud rate and transfer delay values
• Clock phase
• Clock polarity
• MSB/LSB first
DSPIx_POPR
Method 2:
SIU_DISR
Hence,
SIU.DISR.R = 0x00000000;
By using FMPLL
DBR = 0 When
BR = 0000
8 bit per frame
Hence,
DSPI_C.CTAR[0].R = 0x38000000;
TIFAC - CORE IN AUTOMOTIVE INFOTRONICS, VIT
Sponsored by Dept. of Science & Technology, Govt. of India
Programming:
Step 4:
Configure pad as in input and output
Hence,
SIU.PCR[107].R = 0x0A00;
SIU.PCR[109].R = 0x0A00;
SIU.PCR[110].R = 0x0A00;
SIU.PCR[108].R = 0x0900;
When ,
Hence,
DSPI_C.PUSHR.R = 0x08010067;
where, TXDATA = 0067;
67 indicates 8 bit data in a frame.
When
RFDF = 0 RX FIFO empty
1 Not Empty
Step 7:
Load Value from POP Register(DSPI_C.POPR.R)
Step 8:
Clear RFDF
Hence,
while(DPSI_C.SR.B.RFDF != 1);
receive = DSPI_C.POPR.;
DSPI_C.SR.R = 00020000;
TIFAC - CORE IN AUTOMOTIVE INFOTRONICS, VIT
Sponsored by Dept. of Science & Technology, Govt. of India
TIFAC - CORE IN AUTOMOTIVE INFOTRONICS, VIT
Sponsored by Dept. of Science & Technology, Govt. of India
CAN System
CAN BUS
NODE-B
NODE-A
AIR CONDITIONER
BUZZER
WHEEL
LCD DISPLAY
VIBRATION SENSOR
LED DISPLAY
MAGNETIC PICKUP SENSOR
NODE-C
NODE-D
NODE-E NODE-F
The module operates receiving and/or transmitting message frames, errors are
handled normally and all the CAN protocol functions are enabled.
2. Freeze Mode:
3. Listen Mode:
FlexCAN operates in a CAN error passive mode, freezing all error counters and
receiving messages without sending acknowledgments.
FlexCAN performs an internal loop back that can be used for self test operation.
Hence,
CAN_A.MCR.R = 0x0000003F;
If CLK_SRC = 0,
PRESDIV = 00000100 = 4,
Ftq = 8 MHz / 5 = 1.6 MHz
Therefore, 100 KHz Bit Time = 1.6 MHz / No. of Time Quanta
Hence, No. of Time Quanta = 16
So, PSEG1 = PSEG2 = 3 Hence,
PROPSEG = 6
HENCE, TS1 = 11, TS2 = 4
CAN_A.CR.R = 0x04DB0006;
Hence,
Step 4:
To In activate TX for Message Buffer 0
Hence,
CAN_A.BUF[0].CS.B.CODE = 8;
Hence,
SIU.PCR[83].R = 0x0620;
SIU.PCR[84].R = 0x0500;
Step 6: (In Transmitting Side)
Select Standard / Extended ID
Standard – 0
Extended – 1
Hence, CAN_A.BUF[0].CS.B.IDE = 0;
Step 8:
Set RTR as Data Frame
Remote Frame = 1 Hence,
CAN_A.BUF[0].CS.B.RTR = 0;
Data Frame = 0
Step 9:
Specify the Length of the Tx’ng Data
Hence,
CAN_A.BUF[0].CS.B.LENGTH = sizeof(TxData) – 1 ;
Step 12:
Activate Message Buffer.
Hence,
CAN_A.BUF[0].CS.B.CODE = 0xC;
Step 15:
Activate Message Buffer.
Hence,
CAN_A.BUF[0].CS.B.CODE = 0xC;