Cannot config SBC by 8-bit per frame in s32k144

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Cannot config SBC by 8-bit per frame in s32k144

跳至解决方案
1,338 次查看
DaoVan
Contributor II

Hi, I'm currently using "sbc_uja116x_s32k144" example in SDK. When I changed .bitcount from 16 to 8 the SBC driver init will return error and go in to while loop of DEV_ASSERT(), even I changed .isPcsContinuous = true.

As my observation, in the example only send 2 byte per frame. Anyone has any idea for sending 3, 4 bytes per frame. Thank you.

const lpspi_master_config_t lpspiCom1_MasterConfig0 = {
.bitsPerSec = 300000U,
.whichPcs = LPSPI_PCS3,
.pcsPolarity = LPSPI_ACTIVE_LOW,
.isPcsContinuous = false,
.bitcount = 8U, (in the original of SDK is 16U)
.lpspiSrcClk = 8000000U,
.clkPhase = LPSPI_CLOCK_PHASE_2ND_EDGE,
.clkPolarity = LPSPI_SCK_ACTIVE_HIGH,
.lsbFirst = false,
.transferType = LPSPI_USING_INTERRUPTS,
.rxDMAChannel = 255,
.txDMAChannel = 255,
.callback = NULL,
.callbackParam = NULL,
};

Thank and best regards,

Dao Van

0 项奖励
回复
1 解答
1,257 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

If you use SDK APIs and S32 Configuration Tools, you will only use 16bit.

If you write the SPI driver yourself, then according to the UJA1169 DataSheet description, I think 24bit and 32bit are also possible.

Fig 16. SPI data structure for a write operation (16-, 24- or 32-bit).png

在原帖中查看解决方案

5 回复数
1,326 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Dao Van,

It seems to be caused by UJA1169, please download https://www.nxp.com/docs/en/data-sheet/UJA1169.pdf:
16-, 24- and 32-bit SPI for configuration, control and diagnosis
During a write operation, the UJA1169 monitors the number of SPI bits transmitted. If the number recorded is not 16, 24 or 32, then the write operation is aborted and an SPI failure event is captured (SPIF = 1)


Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" 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 项奖励
回复
1,317 次查看
DaoVan
Contributor II

Hi Robin

Actually, we had one project successfully working with s32k118 send 8-bit per frame LPSPI for configuration SBC UJA1169 with following configuration:

static const spiDrv_lpspi_master_config_t masterSBCConfig0 = {

/* Misra: 1.1 Qac: 1053 Cmt: configuration specific */

.BitsPerSec_u32 = 1000000U,

.WhichPcs_en = SPIDRV_PCS0,

.PcsPolarity_en = SPIDRV_ACTIVE_LOW,

/* Misra: 10.3 Qac: 1297 Cmt: configuration specific */

.IsPcsContinuous_b = TRUE,

.Bitcount_u16 = 8U,

.LpspiSrcClk_u32 = 8000000U,

.ClkPhase_en = SPIDRV_CLOCK_PHASE_2ND_EDGE,

.ClkPolarity_en = SPIDRV_PIN_ACTIVE_HIGH,

.BitOrder_en = SPIDRV_TRANSFER_MSB_FIRST,

.TransferType_en = SPIDRV_USING_POLLING,

.RxDMAChannel_u8 = 255,

.TxDMAChannel_u8 = 255,

.Callback_pst = NULL,

.CallbackParam_pst = NULL,

};

 

With that we can read and write SBC data with 3 and 4 byte like this:

SpiDrv_MasterTransfer(SPI_INST_TYPE_SPI_SBC, TxDataPtr, RxDataPtr, 3);

SpiDrv_MasterTransfer(SPI_INST_TYPE_SPI_SBC, TxDataPtr, RxDataPtr, 4);

1. Do you have any idea for this above point?

2. Regarding the "sbc_uja116x_s32k144" example, we only send 2 bytes per frame correct? if we want to send 3 or 4 bytes we need to config .bitcount = 24 or 32, am I correct?

 

Thank and best regards,

Dao Van

0 项奖励
回复
1,284 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Which version of S32K1 SDK are you using? I am using latest S32K1 SDK RTM4.0.3.
S32CT in S32DS v3.4 does not allow to choose 8bit or 24bit or 32bit:

16 bits per frame required.png

As you can see the driver SBC_DataTransfer use 16bit LSPI. So I am afraid you must select 16 bit LPSPI when using S32K1 SDK.

SBC_InitDevice SBC_DataTransfer.png

I did not find SpiDrv_MasterTransfer function.(Do you mean LPSPI_DRV_MasterTransfer?) Have you modified the S32K1 SDK driver or are you using your own driver?

1,269 次查看
DaoVan
Contributor II

Hi Robin,

Which version of S32K1 SDK are you using? I am using latest S32K1 SDK RTM4.0.3.

--> I'm using S32K1xx SDK 3.0.3

DaoVan_0-1681954421378.png

S32DS v3.4 does not allow to choose 8bit or 24bit or 32bit:

--> That mean if I refer the SDK example, I will only send 16bit, right?

I did not find SpiDrv_MasterTransfer function.(Do you mean LPSPI_DRV_MasterTransfer?)

--> Yes, correct

Have you modified the S32K1 SDK driver or are you using your own driver?

--> Actually, we are referring the sdk driver with a little bit our changes.

0 项奖励
回复
1,258 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

If you use SDK APIs and S32 Configuration Tools, you will only use 16bit.

If you write the SPI driver yourself, then according to the UJA1169 DataSheet description, I think 24bit and 32bit are also possible.

Fig 16. SPI data structure for a write operation (16-, 24- or 32-bit).png