FS26 MSPI_CRC_I bit set in M_COM_FLG register

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FS26 MSPI_CRC_I bit set in M_COM_FLG register

3,169 Views
ben1111
Contributor I

Hi, I trying to read out the M_DEVICEID register on the FS26 PMIC/SBC deivce from a S32K3 MCU with SPI, and I get the correct values for device ID, but a lot of Flags are set in the "General device status" bits response.
E.g. I see that bit COM_G is set, so I read out M_COM_FLAG and see that bit MSPI_CRC_I is set (CRC not valid).
I've tried different CRC calculations provided by AI assistance and all of them give the same result but get the CRC fault anyway.

This is what my SPI communication looks like.

Reading of M_DEVICEID register:


spi_read_m_deviceid.png

Reading of M_COM_FLG register:

spi_read_m_com_flag.png

As can be seen, both responses from FS26 gives 254 for General Device Status bits.
And in the last message (M_COM_FLG) the data is 0x04, which is MSPI_CRC_I.

In the above SPI messages I calculate CRC for reading M_DEVICEID register as 166 (0xA6) but the FS26 respond with 150 (0x96).
And for reading M_COM_FLG register I calculate and send CRC = 234 (0xEA) but FS26 respond with CRC 251 (0xFB).

These are the C function to calculate 8bit CRC:

 

uint8_t FS26_CalculateCRC(
    uint8_t byte0,
    uint8_t byte1,
    uint8_t byte2,
    uint8_t byte3)
{
    uint8_t crc = 0xFF;      // Seed
    uint8_t poly = 0x1D;

    // Data bytes used in CRC calculation:
    // byte0 = bit31..24
    // byte1 = bit23..16
    // byte2 = bit15..8
    // byte3 = CRC byte, assumed to be 0x00 during calculation

    uint8_t data[4];
    data[0] = byte0;
    data[1] = byte1;
    data[2] = byte2;
    data[3] = byte3;   // CRC byte cleared during calculation

    for (int byte = 0; byte < 4; byte++)
    {
        crc ^= data[byte];

        for (int bit = 0; bit < 8; bit++)
        {
            if (crc & 0x80)
            {
                crc = (crc << 1) ^ poly;
            }
            else
            {
                crc <<= 1;
            }
        }
    }

    return crc;
}
 
and the function above is called like this (where CRC is set intially to 0):

uint8_t crc = FS26_CalculateCRC(
            masterTxData[0],
            masterTxData[1],
            masterTxData[2],
            0);
 
masterTxData[3] = crc;
 
Tags (1)
0 Kudos
Reply
3 Replies

3,103 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi

First, let me clarify that I am an S32K technical support engineer, so I am not familiar with FS26.

I installed SW32K3_RTD_R23-11_7.0.0_P01_D2602_DesignStudio_updatesite.zip and S32K3_SBC_FS26_R23-11_6.0.0_D2511_DesignStudio_updatesite.zip in S32DS v3.6.4.

At the end of the main function of Sbc_fs26_example_IP_S32K344, M_DEVICEID and M_COM_FLG are read using Sbc_fs26_ReadRegister().

I did not calculate the CRC by myself. The Sbc_fs26_ReadRegister()function appears to call Sbc_fs26_CalcCrc() to calculate the CRC value.

Sbc_fs26_CalcCrc Sbc_fs26_TransferData Sbc_fs26_ReadRegister Sbc_fs26_example_IP_S32K344.png

/* This function calculates CRC value of passed data array. */

static uint8 Sbc_fs26_CalcCrc(const uint8* pu8Data)

{

uint8 u8Crc = SBC_FS26_COM_CRC_INIT_U8; /* Result. */

uint8 u8TableIdx = 0U; /* Index to the CRC table. */

uint8 u8DataIdx = 0U; /* Index to the data array (memory). */

 

/* Calculate CRC. */

for (u8DataIdx = 0U; u8DataIdx < (SBC_FS26_COMM_FRAME_SIZE_U8 - 1U); u8DataIdx++)

{

u8TableIdx = u8Crc ^ pu8Data[u8DataIdx];

u8Crc = au8CrcTable[u8TableIdx];

}

 

return u8Crc;

}

 

Please also check the SPI configuration:

Sbc_fs26_example_IP_S32K344 SBC FS26 R23-11 6.0.0 Lpspi configuration.png
Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "ACCEPT AS SOLUTION" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

-------------------------------------------------------------------------------

0 Kudos
Reply

2,847 Views
ben1111
Contributor I

Hi, thanks for the reply.

The thing is, we're actually using the MCXE31B chip (which is the same as S32K3xx) with MCUXpresso sdk, so I haven't got Design studio. But I downloaded it and tried to install the real-time drivers and SBC/FS26 code but wasn't able to do it.

Could you please provide me with the complete function, the macro (SBC_FS26_COMM_FRAME_SIZE_U8) and the crc table au8CrcTable[].
Also give me the function Sbc_fs26_ReadRegister() calls the function Sbc_fs26_CalcCrc() so I can see how it is used.

Thank you!

0 Kudos
Reply

2,791 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Please install SW32K3_RTD_R23-11_7.0.0_P01_D2602_DesignStudio_updatesite.zip and S32K3_SBC_FS26_R23-11_6.0.0_D2511_DesignStudio_updatesite.zip in S32DS v3.6.6 by refer to How To Download, Install and Configure the RTD 5.0.0 with S32 Design Studio 3.6.0

SW32K3_RTD_R23-11_7.0.0_P01_D2602_DesignStudio_updatesite.zip can be download by click S32K3 Standard Software -> Automotive SW - S32K3/S32M27x - Real-Time Drivers for Cortex-M -> S32K3 Real-Time Drivers AUTOSAR R23-11 Version 7.0.0 P01

S32K3_SBC_FS26_R23-11_6.0.0_D2511_DesignStudio_updatesite.zip can be download by click S32K3 Standard Software -> Automotive SW - SBC/PMIC - Real Time Drivers -> SBC FS26 R23-11 6.0.0

Then you will be able to find the Sbc_fs26_example_IP_S32K344

Sbc_fs26_example_IP_S32K344 File New S32DS Project From Example.png

0 Kudos
Reply