This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to make communication between two stm8s+nrf24l01 (ie.one(stm8s+nrf24l01) as transmitter and one(stm8s+nrf24l01) as receiver)?can anyone help

hello , i am trying to make communication between two (stm8s+nrf24l01) modules for which i am using this link zewaren.net/.../110, by this code i am able to transmit data from one side and receive data to the another side but it can happen only one next time i will not able to send data and receive data. can anyone please tell me why it is happening by refering this code. or if anyone had made this communication then will you please share your code.or give me suggestions. controller:stm8s and nrf24l01 IDE:IAR workbench

Thank you

Pallavi

  • Hi Pallavi

    A quick test: Are you changing the payload for each packet, or is it always the same?

    Best regards

  • Hello sir,

    i am not changing the payload i am using the given code as it is.

    Pallavi

  • Hi

    Can you try to add an incrementing counter in the packet and see if it solves the issue?

    If it does then the problem is most likely that the nRF24L01 TX module is being reset between each packet, so that the packet is discarded in the receiver as a re-transmission.

    If the payload content, address and PID is identical between packets then the packet will be discarded.

    Best regards

  • hello sir,

    May be you are right cz i also think on that and finally made tha conclusion that is,may be Tx module is getting reseted after one transmission.you told that " If the payload content, address and PID is identical between packets then the packet will be discarded. " what does it mean i am not understanding this thing will you please elaborate.

    Thank You,

    Pallavi

  • Hi
    As you know the PRX will automatically send an ACK packet after receiving a packet from the PTX, to tell the PTX that the packet was successfully received.
    If the ACK is not received by the PTX the PTX will assume that the packet was lost, and send the exact same packet one more time (up to 15 times maximum). This packet will have an identical payload, address and PID.
    But some times the ACK could also get lost. In this case the PTX will resend the same packet, even though it was already received by the PRX. When this happens the PRX will recognize the retransmitted packet as being a duplicate, it will send an ACK to the PTX to tell it that the packet has been received, but it will not raise the RX_DR interrupt and will not put the packet into the RX FIFO (because it already did that earlier).
    There is no timeout on this mechanism, so even if you send a new packet much later the packet will be discarded on the PRX side as a retransmit.
    Normally this is not an issue since the PID is incremented every time you upload a new packet to the PTX, but if the nRF24L01 is reset in between each packet then the PID will always be the same. In this case you would have to either add some changing data in the payload, or make sure to send at least two packets in between each wakeup (then the PID will have different values, and the problem goes away).

    Best regards
    Torbjørn

Related