FREEDM K22F SPI Communication with LoRa SX1276

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

FREEDM K22F SPI Communication with LoRa SX1276

Jump to solution
4,955 Views
CK3
Contributor III

Hi,

I am currently working with the FRDM-K22F and trying to communicate with a LoRa Module based on the Semtech SX1276 via SPI. I want to read and write from/to the LoRa module. I am sending the address and value in an array in Single access mode. My problem is that the replies from the LoRa module are simply wrong and it is not working.
How do I know that it's wrong? I have a fully functional Setup with Arduino and LoRa SX1276 (also via SPI communication) and can read the outputs.

  • I am using the dspi_half_duplex_int_master SDK for communication for K22F
  • The Arduino is using the default Arduino LIbray for SPI communication.

This means, that in Arduion I am using the spi->transfer() function, whereas in the K22F I am 

  1. DSPI_MasterInit()
  2. DSPI_MasterTransferCreateHandle()
  3. DSPI_MasterHalfDuplexTransferNonBlocking()

to send.

I have already checked the following:

  • I have checked the buffers and the sent content is correct.
  • I have checked the clock frequency and tested various values. Also to no avail
  • SPI-mode is the same as in Arduinos case (CPHA=0, CPOL=0)
  • slave-select line (with an oscilloscop) and that's ok. Both are sent in MSB so that's also fine.
  • Checked SPI communication between K22F(master) and Arduino(slave) as a test, so sending works.

At this point I don't know what further error sources to pursue. For the LoRa code I am using these examples: GitHub - sandeepmistry/arduino-LoRa: An Arduino library for sending and receiving data using LoRa ra... and this one GitHub - loraraspi91/LoRa4Raspi

One difference I could observe with the help of the oscilloscop is that in the case of the K22F there are 4 flanks on the MOSI line in one Single access whereas on the Arduino there are only 2. I am not sure if that is of any use.

thanks for any help!

0 Kudos
1 Solution
4,938 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

Hope you are well. I will gladly help you with this.
I suggest you use the function "DSPI_MasterTransferNonBlocking()" you can find an example of how to use it in the SDK example "dspi_interrupt_b2b_transfer_master".

Arduino uses a full-duplex scheme for the SPI so I suggest you refer to that example that is not in half-duplex.

Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar

View solution in original post

0 Kudos
4 Replies
4,939 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

Hope you are well. I will gladly help you with this.
I suggest you use the function "DSPI_MasterTransferNonBlocking()" you can find an example of how to use it in the SDK example "dspi_interrupt_b2b_transfer_master".

Arduino uses a full-duplex scheme for the SPI so I suggest you refer to that example that is not in half-duplex.

Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar

0 Kudos
1,990 Views
gnps44
Contributor I

Hi Omar

Hope you are well.

Could you please help me find this example or function definition? I have been looking online and can't trace it.

Also, do you think this would work on the KL25Z?

Thank you very much

0 Kudos
4,927 Views
CK3
Contributor III

Ok, I was now able to try it out with the DSPI_MasterTransferNonBlocking() and it works. Thanks a lot!

0 Kudos
4,930 Views
CK3
Contributor III

Hi,

I hope you are also well.
Is this a problem, that the example SDK I use is half-duplex? From what I have read, half-duplex does not exist for SPI, since the master is always responsible for transfer.

Kind regards,
CK

0 Kudos