LonelyWolf / stm32

STM32 stuff
The Unlicense
962 stars 494 forks source link

nrf24l01 #8

Closed hamed-ta closed 7 years ago

hamed-ta commented 8 years ago

hello and thank you for these great libraries

how can I send data by nrf24l01 in this library ?

I use this code but always gives me UnSuccess & UnSuccess nRF24_MASK_MAX_RT

nRF24_TXMode();
Delay_ms(10);

           status = nRF24_TXPacket(txBuf,TX_PAYLOAD);
        if (status & nRF24_MASK_TX_DS)
        {
            UART_SendStr("---SEND-->>> Success\n");

        } else if (status & nRF24_MASK_MAX_RT)
        {
          UART_SendStr("---SEND-->>> UnSuccess nRF24_MASK_MAX_RT\n");
        } else
        {
             UART_SendStr("---SEND-->>> UnSuccess \n");
        }
LonelyWolf commented 8 years ago

When you got MAX_RT bit set after transmit, this means what the nRF24 did not received an ACK packet from the receiver side. The reasons can be: poor reception, incorrectly configured receiver, etc. As for receiver configuration: if you use the auto acknowledgement, then you must properly configure the PIPE#0 on the receiver side (address of the transmitter for auto ack, transmit power).

And this "library" (if you use the one from the "Nrf24l01" directory in that repo) is very old and contains some nasty errors. Didn't remember all of them, but the royal one is that the address is programmed in reverse order, e.g. if you program it as "12345", then actually in the nRF24 it will be "54321" and if your receiver side is configured by other soft (what programs the address correctly), nothing will work.

In the "stm32l151rdt6-dev" directory present more recent nrf24.c, but I don't like it too. I have more decent "library" for nRF24, but I've not uploaded it to github yet. It needs an usage example, but right now I don't have free time for it.

hamed-ta commented 8 years ago

it contains a lots of errors in transmit methods , i try to fix it but still has errors could you please upload the other lib you have ?

LonelyWolf commented 8 years ago

I've re-uploaded the nRF24 project with new library and some stupid demo code (TX and RX). Look at it, maybe it will be useful. I've especially got my old good F103 boards and write a demo code using SPL...

I've tried to write this library 'hardware-independent', with purpose of moving to other platform with minimal code changes. So far it worked on STM32L151, STM32L476, STM32F103, STM8L151 and Raspberry Pi3 (not by me)... On the STM32 I can note one issue: when your CPU is really fast and the SPI speed is really slow, the code can fail due to early CSN pin de-assertion (while the SPI clock didn't finished last bit transmission). Maybe the CSN pin handling should be removed from nRF24 code... maybe other solution... I don't know yet. Arghhh... my pidgin english, I can't describe that issue properly :)

hamed-ta commented 8 years ago

it's great thank you , i'm going to test it.

hamed-ta commented 7 years ago

it works , but when I want to test it with Auto-ACK mode enable the receiver only received once and the transmitter got [1E] MAX RETRANSMIT ! why ? i just comment //nRF24_DisableAA(); in DEMO_TX_SINGLE section and comment nRF24_DisableAA(); and set nRF24_SetRXPipe to nRF24_AA_ON in DEMO_RX_SINGLE section ! do I need change something else to enable Auto-ACK in tx and rx single mode ?

LonelyWolf commented 7 years ago

On the receiver part, have you set a correct transmit power level? Because default it is at the lowest value. Imagine situation: your TX part transmits at 0dBm (yelling), the RX part receives the packet, automatically switches to TX mode and replies with ACK packet at the -18dBm (whispers). As a result your transmitter did not hears the answer and retransmits the packet...

hamed-ta commented 7 years ago

I added nRF24_SetTXPower(nRF24_TXPWR_0dBm); to receiver section but it doesn't affect , however the transmitter and receiver are very close , I think there is a issue in the code ?

LonelyWolf commented 7 years ago

LOL, how can I say why it isn't working when I didn't see of your code neither hardware... Later I will try ShockBurst on my hardware... But take a little advice: forget about ShockBurst, it's pretty useless, slow and greedy for the power.

LonelyWolf commented 7 years ago

And one more thing comes to mind: on the receiver side, have you configured address for pipe#0 same as address on the TX side? The ShockBurst retransmits ACK packets using address of pipe#0.

hamed-ta commented 7 years ago

about code I use exactly your sample code , and about hardware I use simple STM32F103RET6 training board just to test NRF module and about ShockBurst I just want to use Auto-ACK mode to ensure the success of transmission .

LonelyWolf commented 7 years ago

I've played with ShockBurst, added a couple of functions for better handling of that feature. All working. Look at examples, if it doesn't help - RTFM (really, read datasheet, it written pretty good).

hamed-ta commented 7 years ago

Thank you for this ;) I really appreciate

LonelyWolf commented 7 years ago

I'm not familiar with C++ and not shure what you want to do, but if it will be something usefull... it will be great. Let's see :)

hamed-ta commented 7 years ago

Ok

LonelyWolf commented 7 years ago

Looks good, but I'm not familiar with the C++, so can't judge about it :) So... what I've supposed to do?

LonelyWolf commented 7 years ago

No, I don't want to share my contacts :)

hamed-ta commented 7 years ago

Ok , thank you ;)