Hi @davidtosenovjan @PetrS,
We captured SPI signals at different frequencies and attempted to read various registers, including the 32-bit OSC and 32-bit C1CON (0x000) registers. We found the C1CON register particularly useful for analysis, as all bytes have some values.
We have set a delay between frame-to-frame using the PDT and DT parameters. We observed a noticeable difference in the delay between frames at 16.5 MHz, 8.5 MHz, and 11 MHz. While the oscilloscope shows the data correctly, the software fails to capture the one byte.
Data Expected to Receive: -0x60079804
Data on SPI Bus -0x60079804
Data received on Software below 16.5Mhz- 0x600798xy
void spi_initialize(spi_config_t *spi_config)
{
uint8_t i = 0;
// todo: Need to Improve this function , this is very starting point
// Configure GPIO pins
// CLK set to Primary Function, Output and max slew rate
SIU.PCR[spi_config->bus_pins.sck].R = PCR_SCK;
// MISO set to Primary Function, Input, and Weak Pullup
SIU.PCR[spi_config->bus_pins.miso].R = PCR_MISO;
// MOSI set to Primary Function, Output, and Max Slew Rate
SIU.PCR[spi_config->bus_pins.mosi].R = PCR_MOSI;
// set chip select enable
for (i = 0; i < MAXIMUM_SLAVES; i++)
{
if (spi_config->chip_select[i] != 0)
{
SIU.PCR[spi_config->chip_select[i]].R = GPIO_PCR_WRITE;
SIU.GPDO[spi_config->chip_select[i]].B.PDO = eCS_HIGH;
}
}
if (spi_config->write_prot.has_wr_prot)
{
SIU.PCR[spi_config->write_prot.wr_prot].R = GPIO_PCR_WRITE;
SIU.GPDO[spi_config->write_prot.wr_prot].B.PDO = eCS_LOW;
}
// Stop the DSPI interface
spi_config->port->MCR.B.HALT = 1;
// Configure DSPI interface
spi_config->port->MCR.B.MSTR = 1; // Master Mode
spi_config->port->MCR.B.DIS_TXF = 1; // No TX Queue
spi_config->port->MCR.B.DIS_RXF = 1; // No RX Queue
spi_config->port->MCR.B.CONT_SCKE = 0; // No Continuous Clock
spi_config->port->MCR.B.DCONF = 0; // SPI
spi_config->port->MCR.B.MTFE = 0; // Modified Timing Disabled
spi_config->port->MCR.B.PCSSE = 0; // Unused
spi_config->port->MCR.B.ROOE = 1; // RX Overwrite
spi_config->port->MCR.B.DOZE = 0; // No Doze
spi_config->port->MCR.B.SMPL_PT = 0; // Sample Point
// Configure CTAR0 (Clock and Transfer Attributes Register)
spi_config->port->CTAR[0].B.DBR = 0; // No Baud Rate Doubling
spi_config->port->CTAR[0].B.FMSZ = 7; // 8 Bit Frame
spi_config->port->CTAR[0].B.CPHA = 0; // Capture on Rising Edge, SPI-0 Mode
spi_config->port->CTAR[0].B.LSBFE = 0; // MSB First
spi_config->port->CTAR[0].B.PCSSCK = 0; // PCS to SCK Delay Prescaler
spi_config->port->CTAR[0].B.PASC = 0; // Last SCK to PCS delay Prescaler
spi_config->port->CTAR[0].B.PDT = 1; // Frame to Frame Delay Prescaler
spi_config->port->CTAR[0].B.PBR = 0; // Baud Rate Prescaler
spi_config->port->CTAR[0].B.CSSCK = 0; // PCS to SCK Delay Scaler
spi_config->port->CTAR[0].B.ASC = 0; // After SCK Delay Scaler
spi_config->port->CTAR[0].B.DT = 1; // Frame to Frame Scaler
spi_config->port->CTAR[0].B.BR = (uint8_t)(spi_config->baud_rate_scale); // Baud Rate Scalerspi_config
// Calculate and verify SCK based on:
// SCK = (fPeriph / PBR) * (1 + DBR) * (1 / BR)
// = (132MHz / 2) *(1 + 0) *( 1 / config->baud_rate_scale)
// where fPeriph is the peripheral clock frequency, typically 132MHz as per absolosence board
// Enable SPI
spi_config->port->MCR.B.HALT = 0;
}
Command Sequence
REG_C1CON(0x000)@8.5MHz
REG_C1CON(0x000)@10.5MHz
REG_C1CON(0x000)@16.5MHz
Debug_Console@8.5Mhz
Debug_Console@16.5Mhz
Note: Other slaves, such as FRAM and Flash, are working fine in all frequencies
Kindly refer to the images below, along with the debug console outputs, for further inputs.
Thanks & regards
Narendra
MPC5674F