how to use SLAVE spi with interrupt

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

how to use SLAVE spi with interrupt

1,073 Views
mcristian
Contributor II

Hello all,

I am using S32K148 LQFP176, and I am trying to get data from from another device, using SPI. Thus, I am trying to use LPSPI0 with the following pins: PTD15 (LPSPI0_SCK as input), PTD16 (LPSPI0_SIN as input), PTA30 (LPSPI0_SOUT as output) and PTA26 (LPSPI0_PCS0)

For initializing the slave state, I was using this function: LPSPI_DRV_SlaveInit(INST_LPSPI_1, &lpspi_2State, &lpspi_1_SlaveConfig0);

For adding the interrupt I was using the following functions:

INT_SYS_InstallHandler(LPSPI0_IRQn, SPI0_Slave_ISR, (isr_t*) 0);
INT_SYS_EnableIRQ(LPSPI0_IRQn);
 
To get the data, I was expecting to have one register which I need to check it every time when the SPI0_Slave_ISR function is called, but I don't know how to read the data.
Is there any example or can you give me some details how to get the SPI data?
0 Kudos
Reply
5 Replies

1,046 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @mcristian,

With SDK it is not possible to check if the data from slave data is ready all the lpspi register operations are done in the background. Please check the following community post: Solved: How do I know if the SPI slave has received the data? - NXP Community. An spi example is shared where there is a callback function used.

There is also the Lpspi_Ip_HalfDuplex_Transfer_S32K148 example from the RTD package which uses interrupt for the transfer. You can go into the Lpspi_Ip_IrqHandler function which is called by LPSPI ISR to analyze how the transfer is processed in interrupt mode.

Best regards,
Julián

 

0 Kudos
Reply

1,028 Views
mcristian
Contributor II

Thanks @Julián_AragónM  for the answer. 

I was able to install RTD but I have some issues. 

1. First, I have a compilation problem:

Error: Program "" not found in PATH
PATH=[C:/NXP/S32DS.3.4/eclipse/jre/bin/server;C:/NXP/S32DS.3.4/eclipse/jre/bin;C:/NXP/S32DS.3.4/eclipse/jre/lib/amd64;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\Pico Technology\PicoScope6\;C:\Program Files\Microchip\xc8\v2.41\bin;C:\Program Files (x86)\Microchip\xc8\v2.00\bin;C:\Program Files (x86)\Microchip\xc8\v1.45\bin;C:\Program Files\PuTTY\;C:\Program Files\Microchip\xc16\v2.10\bin;C:\Program Files\WindowsPowerShell\Scripts\HP.ClientScriptLibrary;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microchip\xc16\v2.00\bin;C:\Program Files\Microchip\xc16\v1.70\bin;C:\Program Files\Microchip\xc16\v1.61\bin;C:\Program Files (x86)\Microchip\xc16\v1.41\bin;C:\Program Files\Microchip\xc16\v1.50\bin;C:\Users\uie69050\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\uie69050\AppData\Local\Programs\Python\Python310\;C:\Users\uie69050\AppData\Local\Microsoft\WindowsApps;C:\Users\uie69050\AppData\Local\GitHubDesktop\bin;C:\Python27\;C:\Users\uie69050\Infineon\LauncherService;C:\NXP\S32DS.3.4\S32DS\tools\S32Trace\bin;C:\NXP\S32DS.3.4\eclipse]

 

2. Somehow it seems that the installation was not done properly. I have attached the folder structure. On another project downloaded from the forum, there are "generate" and "RTD" folders, and I cannot find those in my structure

0 Kudos
Reply

1,025 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @mcristian,

S32DS 3.4 supports RTD 1.0.0 & 2.0.0, please confirm you are installing one of these versions. Also, try re-importing the project and follow the "description.txt" file.

Normally, the "Program "" not found in PATH" refers to an error while importing the project, or if a different version was used to develop said project.

Best regards,
Julián

0 Kudos
Reply

1,006 Views
mcristian
Contributor II

Hello @Julián_AragónM ,

In image attached you can see the installed packages. The packages seems to be fine installed. Also reimporting the project was not working. 

When I am checking the configuration. I see the following warning message:

Orphaned configuration. No base extension cfg exists for com.nxp.s32ds.cle.arm.mbs.arm32.bare.gnu.10.2.exe.debug.1072142349

I don't have any Build Variables and also the PATH variable is missing from Environment tab. Please check the image attached

0 Kudos
Reply

1,001 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @mcristian,

I apologize, I mistakenly said S32DS 3.4 supports both RTD 1.0.0 and 2.0.0. S32 Design Studio v3.4 only supports RTD 1.0.0. Please uninstall your current package and install RTD 1.0.0 instead.

If the problem persists, please try some of the solutions on the following community posts:

Best regards,
Julián

0 Kudos
Reply