S32DS SPI CS_VIA_GPIO

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

S32DS SPI CS_VIA_GPIO

跳至解决方案
2,111 次查看
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 项奖励
回复
1 解答
1,839 次查看
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 项奖励
回复
6 回复数
2,073 次查看
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 项奖励
回复
2,071 次查看
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 项奖励
回复
2,068 次查看
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,901 次查看
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 项奖励
回复
1,840 次查看
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 项奖励
回复
1,833 次查看
Djuric
Contributor III

Thank you.

0 项奖励
回复
%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%3E%E4%BD%A0%E5%A5%BD%3C%2FP%3E%3CP%3E%E6%88%91%E5%8F%AF%E4%BB%A5%E5%9C%A8%20sbc_fs26_HLD%20%E7%A4%BA%E4%BE%8B%E4%B8%AD%E7%9C%8B%E5%88%B0%20Spi%20%E5%85%83%E5%99%A8%E4%BB%B6%20(MCAL)%20%E4%B8%AD%E6%9C%89%E4%B8%80%E4%B8%AA%E9%80%89%E9%A1%B9%E5%8F%AF%E4%BB%A5%E8%AE%BE%E7%BD%AE%20CS%20%E5%BC%95%E8%84%9A%EF%BC%8C%E5%AE%83%E5%85%81%E8%AE%B8%E6%89%8B%E5%8A%A8%E6%8E%A7%E5%88%B6%20CS%20%E5%BC%95%E8%84%9A%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%3E%E4%BD%86%E6%98%AF%E5%A6%82%E6%9E%9C%E6%88%91%E4%B8%8D%E6%83%B3%E4%BD%BF%E7%94%A8%20MCAL%20%E5%B1%82%EF%BC%8C%E6%88%91%E4%B8%8D%E6%B8%85%E6%A5%9A%E8%BF%99%E4%B8%AA%E9%80%89%E9%A1%B9%E5%9C%A8%E5%93%AA%E9%87%8C%E3%80%82%3CBR%20%2F%3E%E5%9B%A0%E6%AD%A4%EF%BC%8C%E5%AE%83%E4%B8%8D%E6%98%AF%E6%8C%89%E7%85%A7%20AUTOSAR%20%E6%A1%86%E6%9E%B6%E5%B7%A5%E4%BD%9C%E7%9A%84%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E5%9C%A8%E5%90%8C%E4%B8%80%E7%B1%BB%E5%9E%8B%E7%9A%84%E7%A4%BA%E4%BE%8B%E4%B8%AD%EF%BC%8C%E4%BD%86%E5%9C%A8%E4%B8%8D%E7%AC%A6%E5%90%88%20AUTOSAR%20%E6%A0%87%E5%87%86%E7%9A%84%20Sbc_fs26_example_IP%20%E7%89%88%E6%9C%AC%E4%B8%AD%EF%BC%8C%E6%88%91%E6%B2%A1%E6%9C%89%E8%AF%A5%E9%80%89%E9%A1%B9%E3%80%82%3CBR%20%2F%3E%3CSTRONG%3E%E5%9C%A8%E9%9D%9E%E8%87%AA%E5%8A%A8%E6%90%9C%E7%B4%A2%E7%A4%BA%E4%BE%8B%E4%B8%AD%EF%BC%8C%E4%BD%9C%E4%B8%BA%20GPIO%20%E5%BC%95%E8%84%9A%E6%8E%A7%E5%88%B6%E7%9A%84%20SPI%20CS%20%E9%80%89%E9%A1%B9%E5%9C%A8%E5%93%AA%E9%87%8C%EF%BC%9F%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%3E%E8%B0%A2%E8%B0%A2%EF%BC%81%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%3E%E4%BD%A0%E5%A5%BD%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%3C%2FP%3E%0A%3CP%3E%E8%AF%A5%E5%BC%95%E8%84%9A%E5%8F%AA%E8%83%BD%E9%85%8D%E7%BD%AE%E4%B8%BA%20GPIO%EF%BC%8C%E8%80%8C%E4%B8%8D%E8%83%BD%E9%85%8D%E7%BD%AE%E4%B8%BA%20SPI%20%E5%BC%95%E8%84%9A%E3%80%82%E4%BE%8B%E5%A6%82%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%9C%A8%E6%8F%92%E9%92%88%E5%B7%A5%E5%85%B7%E4%B8%AD%E8%BF%99%E6%A0%B7%E5%AE%9A%E4%B9%89%EF%BC%9A%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%3E%E9%85%8D%E7%BD%AE%E5%A6%82%E4%B8%8B%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%3E%E7%84%B6%E5%90%8E%EF%BC%8C%E4%BD%BF%E7%94%A8%20API%20Siul2_Dio_Ip_WritePin()%E6%8E%A7%E5%88%B6%E5%BC%95%E8%84%9A%E7%9A%84%E7%8A%B6%E6%80%81%E3%80%82%20%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%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E5%9B%9E%E7%AD%94%E3%80%82%3CBR%20%2F%3ECS%20%E5%BC%95%E8%84%9A%E4%BF%9D%E7%95%99%E7%BB%99%20Lpspi%20%E5%A4%96%E8%AE%BE%E4%BD%BF%E7%94%A8%EF%BC%8C%E5%A6%82%E4%BD%95%E5%9C%A8%20S32DS%20%E5%B7%A5%E5%85%B7%E4%B8%AD%E5%B0%86%20CS%20%E5%BC%95%E8%84%9A%E9%85%8D%E7%BD%AE%E4%B8%BA%20GPIO%EF%BC%9F%E6%9C%89%E4%B8%80%E4%B8%AA%E5%AE%9A%E4%B9%89%E7%A2%B0%E6%92%9E%E3%80%82%E4%B8%8D%E8%83%BD%E5%9C%A8%E4%B8%A4%E4%B8%AA%E4%B8%8D%E5%90%8C%E7%9A%84%E5%85%83%E5%99%A8%E4%BB%B6%20Lpspi%20%E5%92%8C%20SIUL%20%E4%B8%AD%E5%AE%9A%E4%B9%89%E4%B8%80%E4%B8%AA%E5%BC%95%E8%84%9A%E3%80%82%E4%BD%A0%E8%83%BD%E4%B8%8D%E8%83%BD%E7%BB%99%E6%88%91%E5%8F%91%E4%B8%80%E5%BC%A0%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%EF%BC%8C%E8%AF%B4%E6%98%8E%E5%AE%83%E7%9A%84%E7%A1%AE%E5%88%87%E5%AE%89%E8%A3%85%E4%BD%8D%E7%BD%AE%E3%80%82%E6%88%91%E9%98%85%E8%AF%BB%E4%BA%86%E6%96%87%E6%A1%A3%EF%BC%8C%E6%9C%AC%E7%AB%A0%E6%B6%89%E5%8F%8A%20AUTOSAR%20%E7%8E%AF%E5%A2%83%E4%B8%8B%E7%9A%84%E8%AE%BE%E7%BD%AE%E3%80%82%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%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F232904%22%20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