Transfer/ Receive n bytes & Synchronous Transmit via SPI

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

Transfer/ Receive n bytes & Synchronous Transmit via SPI

Jump to solution
1,381 Views
SuperBeginner
Contributor III

Dear NXP,

I have two questions regarding SPI communication development using MBDT:

  • How can I read or write n bytes (>2 bytes)?
    I have verified that 2-byte data transmission is working fine with the packet generator using the example project "s32k3xx_spi_async_interr_ebt".
    However, when I try to transmit 4 bytes of data (0xAA 0xAB), the EVB only receives the 0xAA data.
    I know this is quite normal, but I just want to provide an example to help you better understand my issue.
  • How do I develop synchronous transmit?
    I referenced the example "s32k344_spi_sync_master_ebt" and tried to start data transmission with LPSPI2, but it doesn’t work.
    I checked the status. "SPI_SetupEB" shows 0 and "SPI_SyncTransmit" shows 1.

    I have confirmed that my hardware connections are normal, as the asynchronous example project works correctly when programmed directly.
    SPI_async_mode.PNG

     

    SPI_async_mode_freemaster.PNG

Please help me. Thank you.

MBDT  S32K312EVB-Q172 

0 Kudos
Reply
1 Solution
1,294 Views
Irina_Costachescu
NXP Employee
NXP Employee

Hi @SuperBeginner 

I would like to point you to the following thread, as a reference to a similar use case that was approached. Could you please check if the solution provided here is suitable for your use case? https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/SPI-configuration-MODEL-based-design-to...

Hope this helps,

Irina

View solution in original post

0 Kudos
Reply
3 Replies
1,306 Views
SuperBeginner
Contributor III

Dear NXP,

Regarding the second question - "How do I develop synchronous transmit?", I found the answer myself.

I found this was an oversight on my part, I didn't enable SpiPhyUnitSync under the S32 Config tool.

SPI_Setting_1.PNG

SPI_Setting_2.PNG

This resulted in my SPI communication not functioning in synchronous mode.

But regarding the first question - "How can I read or write n bytes (>2 bytes)?", I still need your help.

I don't know who can help me.

Please forgive me for now tagging engineers who have helped me in the past.

Thank you.

@Irina_Costachescu  @dragostoma 

0 Kudos
Reply
1,295 Views
Irina_Costachescu
NXP Employee
NXP Employee

Hi @SuperBeginner 

I would like to point you to the following thread, as a reference to a similar use case that was approached. Could you please check if the solution provided here is suitable for your use case? https://community.nxp.com/t5/Model-Based-Design-Toolbox-MBDT/SPI-configuration-MODEL-based-design-to...

Hope this helps,

Irina

0 Kudos
Reply
1,282 Views
SuperBeginner
Contributor III

Hi @Irina_Costachescu ,

Thank you for your reply.

You solved my problem, thanks.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1956107%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ETransfer%2F%20Receive%20n%20bytes%20%26amp%3B%20Synchronous%20Transmit%20via%20SPI%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1956107%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDear%20NXP%2C%3C%2FP%3E%3CP%3EI%20have%20%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3Etwo%20questions%3C%2FFONT%3E%3C%2FSTRONG%3E%20regarding%20SPI%20communication%20development%20using%20MBDT%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3EHow%20can%20I%20read%20or%20write%20n%20bytes%20(%26gt%3B2%20bytes)%3F%3C%2FFONT%3E%3C%2FSTRONG%3E%3CBR%20%2F%3EI%20have%20verified%20that%202-byte%20data%20transmission%20is%20%3CSTRONG%3Eworking%20fine%3C%2FSTRONG%3E%20with%20the%20packet%20generator%20using%20the%20example%20project%20%22%3CSTRONG%3Es32k3xx_spi_async_interr_eb%3C%2FSTRONG%3Et%22.%3CBR%20%2F%3EHowever%2C%20when%20I%20try%20to%20transmit%20%3CSTRONG%3E4%20bytes%3C%2FSTRONG%3E%20of%20data%20(%3CSTRONG%3E0xAA%200xAB%3C%2FSTRONG%3E)%2C%20the%20EVB%20only%20receives%20the%20%3CSTRONG%3E0xAA%3C%2FSTRONG%3E%20data.%3CBR%20%2F%3EI%20know%20this%20is%20quite%20normal%2C%20but%20I%20just%20want%20to%20provide%20an%20example%20to%20help%20you%20better%20understand%20my%20issue.%3C%2FLI%3E%3CLI%3E%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EHow%20do%20I%20develop%20synchronous%20transmit%3F%3C%2FSTRONG%3E%3C%2FFONT%3E%3CBR%20%2F%3EI%20referenced%20the%20example%20%22%3CSTRONG%3Es32k344_spi_sync_master_ebt%3C%2FSTRONG%3E%22%20and%20tried%20to%20start%20data%20transmission%20with%20%3CSTRONG%3ELPSPI2%3C%2FSTRONG%3E%2C%20but%20it%20doesn%E2%80%99t%20work.%3CBR%20%2F%3EI%20checked%20the%20status.%20%22%3CSTRONG%3ESPI_SetupEB%3C%2FSTRONG%3E%22%20shows%20%3CSTRONG%3E0%3C%2FSTRONG%3E%20and%20%22%3CSTRONG%3ESPI_SyncTransmit%3C%2FSTRONG%3E%22%20shows%20%3CSTRONG%3E1%3C%2FSTRONG%3E.%3CBR%20%2F%3E%3CP%3EI%20have%20confirmed%20that%20my%20hardware%20connections%20are%20normal%2C%20as%20the%20asynchronous%20example%20project%20works%20correctly%20when%20programmed%20directly.%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SPI_async_mode.PNG%22%20style%3D%22width%3A%20536px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22SPI_async_mode.PNG%22%20style%3D%22width%3A%20536px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299560i805B3BC25B2CB5A9%2Fimage-dimensions%2F536x277%3Fv%3Dv2%22%20width%3D%22536%22%20height%3D%22277%22%20role%3D%22button%22%20title%3D%22SPI_async_mode.PNG%22%20alt%3D%22SPI_async_mode.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SPI_async_mode_freemaster.PNG%22%20style%3D%22width%3A%20543px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22SPI_async_mode_freemaster.PNG%22%20style%3D%22width%3A%20543px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299559i563E5AF0E217A5D4%2Fimage-dimensions%2F543x166%3Fv%3Dv2%22%20width%3D%22543%22%20height%3D%22166%22%20role%3D%22button%22%20title%3D%22SPI_async_mode_freemaster.PNG%22%20alt%3D%22SPI_async_mode_freemaster.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EPlease%20help%20me.%20Thank%20you.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fc-pwmxy87654%2FMBDT%2Fpd-p%2FMBDT%22%20class%3D%22lia-product-mention%22%20data-product%3D%222259-1%22%20target%3D%22_blank%22%3EMBDT%3C%2FA%3E%26nbsp%3B%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fc-pwmxy87654%2FS32K312EVB-Q172%2Fpd-p%2FS32K312EVB-Q172%22%20class%3D%22lia-product-mention%22%20data-product%3D%223493-1%22%20target%3D%22_blank%22%3ES32K312EVB-Q172%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1958514%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Transfer%2F%20Receive%20n%20bytes%20%26amp%3B%20Synchronous%20Transmit%20via%20SPI%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1958514%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F100054%22%20target%3D%22_blank%22%3E%40Irina_Costachescu%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20reply.%3C%2FP%3E%3CP%3EYou%20solved%20my%20problem%2C%20thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1958406%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Transfer%2F%20Receive%20n%20bytes%20%26amp%3B%20Synchronous%20Transmit%20via%20SPI%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1958406%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239656%22%20target%3D%22_blank%22%3E%40SuperBeginner%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20would%20like%20to%20point%20you%20to%20the%20following%20thread%2C%20as%20a%20reference%20to%20a%20similar%20use%20case%20that%20was%20approached.%20Could%20you%20please%20check%20if%20the%20solution%20provided%20here%20is%20suitable%20for%20your%20use%20case%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FModel-Based-Design-Toolbox-MBDT%2FSPI-configuration-MODEL-based-design-tool-box-32-bit-instruction%2Fm-p%2F1384476%22%20target%3D%22_self%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FModel-Based-Design-Toolbox-MBDT%2FSPI-configuration-MODEL-based-design-tool-box-32-bit-instruction%2Fm-p%2F1384476%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EHope%20this%20helps%2C%3C%2FP%3E%0A%3CP%3EIrina%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1958392%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Transfer%2F%20Receive%20n%20bytes%20%26amp%3B%20Synchronous%20Transmit%20via%20SPI%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1958392%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDear%20NXP%2C%3C%2FP%3E%3CP%3ERegarding%20the%20second%20question%20-%20%22%3CFONT%20color%3D%22%23FF0000%22%3E%3CSTRONG%3EHow%20do%20I%20develop%20synchronous%20transmit%3F%3C%2FSTRONG%3E%3C%2FFONT%3E%22%2C%20I%20found%20the%20answer%20myself.%3C%2FP%3E%3CP%3EI%20found%20this%20was%20an%20oversight%20on%20my%20part%2C%20I%20didn't%20enable%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3E%20SpiPhyUnitSync%3C%2FFONT%3E%3C%2FSTRONG%3E%20under%20the%20S32%20Config%20tool.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SPI_Setting_1.PNG%22%20style%3D%22width%3A%20384px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22SPI_Setting_1.PNG%22%20style%3D%22width%3A%20384px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F300251i7F530B191A0F1210%2Fimage-dimensions%2F384x503%3Fv%3Dv2%22%20width%3D%22384%22%20height%3D%22503%22%20role%3D%22button%22%20title%3D%22SPI_Setting_1.PNG%22%20alt%3D%22SPI_Setting_1.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SPI_Setting_2.PNG%22%20style%3D%22width%3A%20385px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22SPI_Setting_2.PNG%22%20style%3D%22width%3A%20385px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F300250iE7EA56F719338A74%2Fimage-dimensions%2F385x247%3Fv%3Dv2%22%20width%3D%22385%22%20height%3D%22247%22%20role%3D%22button%22%20title%3D%22SPI_Setting_2.PNG%22%20alt%3D%22SPI_Setting_2.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThis%20resulted%20in%20my%20SPI%20communication%20not%20functioning%20in%20synchronous%20mode.%3C%2FP%3E%3CP%3EBut%20regarding%20the%20first%20question%20-%20%22%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3EHow%20can%20I%20read%20or%20write%20n%20bytes%20(%26gt%3B2%20bytes)%3F%3C%2FFONT%3E%3C%2FSTRONG%3E%22%2C%20I%20still%20need%20your%20help.%3C%2FP%3E%3CP%3EI%20don't%20know%20who%20can%20help%20me.%3C%2FP%3E%3CP%3EPlease%20forgive%20me%20for%20now%20tagging%20engineers%20who%20have%20helped%20me%20in%20the%20past.%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F100054%22%20target%3D%22_blank%22%3E%3CFONT%3E%40Irina_Costachescu%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F199423%22%20target%3D%22_blank%22%3E%3CFONT%3E%40dragostoma%3C%2FFONT%3E%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E