S32DS SPI CS_VIA_GPIO

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

S32DS SPI CS_VIA_GPIO

Jump to solution
2,115 Views
Djuric
Contributor III

Hello,

I can see in the  Sbc_Fs26_HLD example that there is an option in the Spi component (MCAL) to set a CS pin, which allows manual control over the CS pin

Djuric_0-1763133632091.png
But I'm not clear where that option is if I don't want to use a MCAL layer.
So, not working according to a AUTOSAR framework.

In the same type of example but in the version Sbc_fs26_example_IP , which is not according to AUTOSAR standard, I don't have that option.
Where is SPI CS as GPIO pin control, option in the non autosar example?

Djuric_1-1763134045440.png

Thank you.

0 Kudos
Reply
1 Solution
1,843 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Djuric 

I have tested a basic LPSPI example in polling mode, using a hardware loopback by connecting the master output to the master input. This setup was used to verify that both transmission and reception are functioning correctly.

To help ensure that no configurations, initializations, or code elements are missing from your setup, I am attaching the .mex file and the main source file for your reference.

Note: The code was developed using S32DS v3.6.2 with RTD 6.0.0 and tested on an S32K3X4EVB-T172.

View solution in original post

0 Kudos
Reply
6 Replies
2,077 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Djuric 

Unlike the SPI driver (MCAL), the LPSPI driver (IP) does not provide an explicit option to indicate whether the CS will be managed via GPIO or by the HW engine. For the IP driver, handling CS through GPIO must be implemented in code, and in ConfigTool you need to configure the desired pin as a GPIO.

Additionally, please note that a low CLK pulse occurs when using the first workaround for ERR050456, which involves resetting the LPSPI module. If you select the second workaround, this low pulse will not appear.

For more details about how to enable the second workaround, refer to Section 3.6.8 of the User Manual for S32K3_S32M27x SPI Driver.

 

BR, VaneB

0 Kudos
Reply
2,075 Views
Djuric
Contributor III

Thanks for the answer.
How do I configure the CS pin in the S32DS tool to be a GPIO, when it is reserved for a Lpspi peripheral. There is a definition collision. One pin cannot be defined in two different components Lpspi and SIUL. Can you send me a screenshot of where this is exactly set up. I read the documentation, this chapter refers to settings in the AUTOSAR context.

0 Kudos
Reply
2,072 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Djuric 

The pin should be configured only as a GPIO, not as an SPI pin. For example, instead of defining it like this in the Pins Tool:

VaneB_0-1763152493107.png

It should be configured as follows:

VaneB_1-1763152562933.png

Then, control the state of the pin using the API Siul2_Dio_Ip_WritePin(). 

1,905 Views
Djuric
Contributor III

Hi @VaneB ,
I followed your advice and these are the steps I took:

1) I unrouted a lpspi1_pcs0 pin from the LPSPI1 peripheral

Djuric_1-1763510420151.png


2) I routed the same pin and declared it as GPIO.

Djuric_2-1763510470230.png


3) Before initiating SPI communication with Lpspi_Ip_SyncTransmit, I would first lower the pin (which simulates the CSB) with Siul2_Dio_Ip_WritePin and then raise it high again after Lpspi_Ip_SyncTransmit.
It is Full Duplex communication, SpiPinConfiguration mode 3.

4) SPI communication is not successful. Do I need to set something here (or somewhere else)?

Djuric_3-1763510648527.png

Could you provide further instructions?
Thank you.

 

 

0 Kudos
Reply
1,844 Views
VaneB
NXP TechSupport
NXP TechSupport

Hi @Djuric 

I have tested a basic LPSPI example in polling mode, using a hardware loopback by connecting the master output to the master input. This setup was used to verify that both transmission and reception are functioning correctly.

To help ensure that no configurations, initializations, or code elements are missing from your setup, I am attaching the .mex file and the main source file for your reference.

Note: The code was developed using S32DS v3.6.2 with RTD 6.0.0 and tested on an S32K3X4EVB-T172.

0 Kudos
Reply
1,837 Views
Djuric
Contributor III

Thank you.

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2205273%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32DS%20SPI%20CS_VIA_GPIO%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205273%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20can%20see%20in%20the%26nbsp%3B%20Sbc_Fs26_HLD%20example%20that%20there%20is%20an%20option%20in%20the%20Spi%20component%20(MCAL)%20to%20set%20a%20CS%20pin%2C%20which%20allows%20manual%20control%20over%20the%20CS%20pin%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Djuric_0-1763133632091.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Djuric_0-1763133632091.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365736i7B6BB675F67EF25C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Djuric_0-1763133632091.png%22%20alt%3D%22Djuric_0-1763133632091.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3CBR%20%2F%3EBut%20I'm%20not%20clear%20where%20that%20option%20is%20if%20I%20don't%20want%20to%20use%20a%20MCAL%20layer.%3CBR%20%2F%3ESo%2C%20not%20working%20according%20to%20a%20AUTOSAR%20framework.%3CBR%20%2F%3E%3CBR%20%2F%3EIn%20the%20same%20type%20of%20example%20but%20in%20the%20version%20Sbc_fs26_example_IP%20%2C%20which%20is%20not%20according%20to%20AUTOSAR%20standard%2C%20I%20don't%20have%20that%20option.%3CBR%20%2F%3E%3CSTRONG%3EWhere%20is%20SPI%20CS%20as%20GPIO%20pin%20control%2C%20option%20in%20the%20non%20autosar%20example%3F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Djuric_1-1763134045440.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Djuric_1-1763134045440.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365737iED9CFEF436E11A49%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Djuric_1-1763134045440.png%22%20alt%3D%22Djuric_1-1763134045440.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205405%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32DS%20SPI%20CS_VIA_GPIO%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205405%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%2F232904%22%20target%3D%22_blank%22%3E%40Djuric%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20pin%20should%20be%20configured%20only%20as%20a%20GPIO%2C%20not%20as%20an%20SPI%20pin.%20For%20example%2C%20instead%20of%20defining%20it%20like%20this%20in%20the%20Pins%20Tool%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22VaneB_0-1763152493107.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22VaneB_0-1763152493107.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365750iB7D36FEE88D596A3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22VaneB_0-1763152493107.png%22%20alt%3D%22VaneB_0-1763152493107.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIt%20should%20be%20configured%20as%20follows%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22VaneB_1-1763152562933.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22VaneB_1-1763152562933.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F365751i901293DC89FD3A6D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22VaneB_1-1763152562933.png%22%20alt%3D%22VaneB_1-1763152562933.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThen%2C%20control%20the%20state%20of%20the%20pin%20using%20the%20API%20Siul2_Dio_Ip_WritePin().%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32DS%20SPI%20CS_VIA_GPIO%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205378%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThanks%20for%20the%20answer.%3CBR%20%2F%3EHow%20do%20I%20configure%20the%20CS%20pin%20in%20the%20S32DS%20tool%20to%20be%20a%20GPIO%2C%20when%20it%20is%20reserved%20for%20a%20Lpspi%20peripheral.%20There%20is%20a%20definition%20collision.%20One%20pin%20cannot%20be%20defined%20in%20two%20different%20components%20Lpspi%20and%20SIUL.%20Can%20you%20send%20me%20a%20screenshot%20of%20where%20this%20is%20exactly%20set%20up.%20I%20read%20the%20documentation%2C%20this%20chapter%20refers%20to%20settings%20in%20the%20AUTOSAR%20context.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2205375%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32DS%20SPI%20CS_VIA_GPIO%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2205375%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%2F232904%22%20target%3D%22_blank%22%3E%40Djuric%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EUnlike%20the%20SPI%20driver%20(MCAL)%2C%20the%20LPSPI%20driver%20(IP)%20does%20not%20provide%20an%20explicit%20option%20to%20indicate%20whether%20the%20CS%20will%20be%20managed%20via%20GPIO%20or%20by%20the%20HW%20engine.%20For%20the%20IP%20driver%2C%20handling%20CS%20through%20GPIO%20must%20be%20implemented%20in%20code%2C%20and%20in%20ConfigTool%20you%20need%20to%20configure%20the%20desired%20pin%20as%20a%20GPIO.%3C%2FP%3E%0A%3CP%3EAdditionally%2C%20please%20note%20that%20a%20low%20CLK%20pulse%20occurs%20when%20using%20the%20first%20workaround%20for%20ERR050456%2C%20which%20involves%20resetting%20the%20LPSPI%20module.%20If%20you%20select%20the%20second%20workaround%2C%20this%20low%20pulse%20will%20not%20appear.%3C%2FP%3E%0A%3CP%3EFor%20more%20details%26nbsp%3Babout%20how%20to%20enable%20the%20second%20workaround%2C%20refer%20to%20Section%203.6.8%20of%20the%20User%20Manual%20for%20S32K3_S32M27x%20SPI%20Driver.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBR%2C%20VaneB%3C%2FP%3E%3C%2FLINGO-BODY%3E