First of all, I'm not very professional, and I'm still learning, so if I ask questions that seem stupid, I hope you can help me answer them, thank you very much;
I am implementing SPI communication function on S32k144 chip, using LPSPI2. The pins used are as follows:
The development tool I use is IAR. My program mimics the code in the lpspi_transfer_s32k144 project and is configured as master. However, when the program reached the LPSPI_Init(base) line in the lPSPI_DRv_Masterinit() function at runtime, it could not continue, and there was a hard fault. I have been debugging for several days, but it still hasn't been solved. I hope anyone can help me. The code is in txt file.
Looking forward to answering. Thank you exeryone.
Hi @648811715,
Firstly, could your share your IDE and SDK version, if possible? Is this the S32K144-EVB or a custom board?
I can see you are using Processor Expert, so firstly I suggest comparing the configuration for Send/Receive LPSPI between the example and your project. Also, please confirm if you have the peripheral clocks available for the LPSPI instance you need (2 in your case).
Best regards,
Julián
Thank you for your response. The board is a custom board. The IDE I use is IAR embedded workbench for ARM 8.32.1. I am not sure about the SDK version, but I know that the program was acquired in 2019, and the library files have not changed since then. Processor Expert probably wasn't actually used because I couldn't find the definition for PEX_ROS_INIT, and I commented out the Processor Expert part of the code and stopped running in the same place. I actually commented out all the code in main, just copied the example code into my main function, and the program stopped running on the same line.
Hi @648811715,
If you are not using PE, I imagine you are building your application through baremetal, or at least hardcoding the configuration. You can use AN5413: S32K1xx Series Cookbook – Application Note for a reference project on SPI (chapter 2.8).
Please go over the configuration for LPSPI and compare it with yours.
Best regards,
Julián
I'm afraid it's really a problem with my SDK version. I have compared some files and they are really different. Maybe I'll have to update the SDK first.
Sorry. My bad. The SPI clock is not configured. No hardware fault appeares after the clock is configured