FRDM - K66F Unable to use LoRa SX1261 Module SPI

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

FRDM - K66F Unable to use LoRa SX1261 Module SPI

Jump to solution
1,642 Views
daniel_mouren
Contributor II

Hi,


I received a semtech SX1261 evaluation kit:
https://www.semtech.com/uploads/documents/UG_DEV_SX126X_W_APP_V1.1.pdf 


I integrated in my evaluation card FRDM K66F this module

So I configured the SPI0 CLOCK, SIN and SOUT.
Then I set up the SS and I put a strap between the PTD0 and the PTA25.

When I run my program, I realized that the SX1261 chip was not responding.
At the logic analyzer I checked the signals SCK, NSS, SOUT and SIN.
SCK, SOUT and NSS have normal activity but the INS is still inactive.

In the Semtech documentation, there is a procedure for Lora to send a transmission (page 98 - 14. Application).
https://www.semtech.com/uploads/documents/DS_SX1261-2_V1.1.pdf 

Is there a NXP program that integrate this chip or another chip of Semtech with LoRa ?
How can I check my SPI configuration?
Is there a way to get a simple answer from the SX 1261 LoRa chip?

cordially

0 Kudos
1 Solution
1,226 Views
daniel_mouren
Contributor II

Hi,

Very thanks Kerry.

I have ask the SemTech community the same question.

Unable to use LoRa SX1261 Module SPI

I retrieved the project proposed by STM enterprise. Lora Ping Pong - STM

I tested on the nucleo card provides.
Pay attention to the rider.

I received the code and I imported it into my project (ping-pong). It still did not work.

2.

Try with Nucleo and check the Ping Pong.

Use one Nucleo for the Ping, and one FRDM K66 for the Pong.

3.

Some error code:

The port is not managed by the spi but by an external gpio.
A jumper will not be enough, it will be coded by writing low then high of this output with each spi command.

    //NSS = 0;
    GPIO_PortClear(
            BOARD_INITPINS_LORA_NSS_GPIO, 1u << BOARD_INITPINS_LORA_NSS_PIN);

   // blah blah blah

   // DSPI_RTOS_Transfer(blah blah blah, blah blah blah);

    //NSS = 1;
    GPIO_PortSet(
            BOARD_INITPINS_LORA_NSS_GPIO, 1u << BOARD_INITPINS_LORA_NSS_PIN);

Via FRDM K66 on the start, there is no timeout (I use FreeRTOS). Force

if( SX126xGetOperatingMode() == MODE_TX )

State = TX_TIMEOUT;

State = RX_TIMEOUT;

After, the Lora has an effective timeout and this code will become useless.

Enable the DIO interrupt and intercept the interrupt.

Code with Irq_Fired must be rewritten.

The imported code ignores the interrupt mode and the normal mode.
Be careful, you have to turn the "blah"_irqProcess function into a task.

For this you will need two semaphores.

g_spi_semaHandle = xSemaphoreCreateBinary();
g_spi_semaHandle2 = xSemaphoreCreateBinary();

xTaskCreate("blah"_irqProcess, "blah", configMINIMAL_STACK_SIZE, NULL, TASK_PRIORITY_VERY_LOW, NULL);

Be careful when importing the code to not include a code error.
After that, and with envy, he ends up walking.

Have a great day,

Daniel

View solution in original post

0 Kudos
5 Replies
1,227 Views
daniel_mouren
Contributor II

Hi,

Very thanks Kerry.

I have ask the SemTech community the same question.

Unable to use LoRa SX1261 Module SPI

I retrieved the project proposed by STM enterprise. Lora Ping Pong - STM

I tested on the nucleo card provides.
Pay attention to the rider.

I received the code and I imported it into my project (ping-pong). It still did not work.

2.

Try with Nucleo and check the Ping Pong.

Use one Nucleo for the Ping, and one FRDM K66 for the Pong.

3.

Some error code:

The port is not managed by the spi but by an external gpio.
A jumper will not be enough, it will be coded by writing low then high of this output with each spi command.

    //NSS = 0;
    GPIO_PortClear(
            BOARD_INITPINS_LORA_NSS_GPIO, 1u << BOARD_INITPINS_LORA_NSS_PIN);

   // blah blah blah

   // DSPI_RTOS_Transfer(blah blah blah, blah blah blah);

    //NSS = 1;
    GPIO_PortSet(
            BOARD_INITPINS_LORA_NSS_GPIO, 1u << BOARD_INITPINS_LORA_NSS_PIN);

Via FRDM K66 on the start, there is no timeout (I use FreeRTOS). Force

if( SX126xGetOperatingMode() == MODE_TX )

State = TX_TIMEOUT;

State = RX_TIMEOUT;

After, the Lora has an effective timeout and this code will become useless.

Enable the DIO interrupt and intercept the interrupt.

Code with Irq_Fired must be rewritten.

The imported code ignores the interrupt mode and the normal mode.
Be careful, you have to turn the "blah"_irqProcess function into a task.

For this you will need two semaphores.

g_spi_semaHandle = xSemaphoreCreateBinary();
g_spi_semaHandle2 = xSemaphoreCreateBinary();

xTaskCreate("blah"_irqProcess, "blah", configMINIMAL_STACK_SIZE, NULL, TASK_PRIORITY_VERY_LOW, NULL);

Be careful when importing the code to not include a code error.
After that, and with envy, he ends up walking.

Have a great day,

Daniel

0 Kudos
1,226 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Daniel,

  So now, do you make it work?

  If not, I suggest you refer to the SDK driver SPI code, not the freertos code, after you can make it works, then you can import it to your freertos system.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,226 Views
daniel_mouren
Contributor II

Hi!

It works perfectly.

:smileylaugh:

0 Kudos
1,226 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi MOUREN Daniel,

   Thanks a lot for your updated information.

   If your question is solved, please help me to mark the correct answer, just to close this post, thank you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,226 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi MOUREN Daniel,

     Unfortunately, we don't have specific K66 SPI code associated with your Lora SX1261.

     But if the K66 SPI can output the correct SPI wave in the SPI bus, the K66 SPI wave also need to meet the slave's SPI wave demand.

     Take example, this information is from your

https://www.semtech.com/uploads/documents/DS_SX1261-2_V1.1.pdf 

page 50.

pastedImage_1.png

So, the K66 CPHA should be 0, CPOL also should be 0:

pastedImage_2.png

The SPI baud rate can't be exceed 16Mhz.

You said you have checked the SPI wave, CS, CLK, MOSI all have data, but the MISO don't have data.

So, the problem should still in the slave control, master SPI wave works, you need to check the SPI slave configuration sequence, what the configuration data need to send to the slave.

You can check it with the your slave's company, find some slave usage control sequence code.

 


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------