This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: Example code does not clear S1CON when clearing RFIRQF1

Part Number: CC2530

Tool/software:

The example code for the CC2530 (SWRC135B.zip) has the following code for transmitting a frame.

uint8 halRfTransmit(void)
{
uint8 status;

ISTXON(); // Sending

// Waiting for transmission to finish
while(!(RFIRQF1 & IRQ_TXDONE) );

RFIRQF1 = ~IRQ_TXDONE;
status= SUCCESS;

return status;
}

Section 23.1.2 of the user guide states that S1CON also needs cleared to clear an interrupt.  The example code for TX does not do this.  The ISR in the example code for RX (rfIsr) does clear S1CON.

Is the example code incorrect or doesn't it matter since it's not inside an ISR?

  • Hi,

    Any time a TX is sent, an RX is active (see basicRfSendPacket --> halRfReceiveOn).

    This means that if the interrupt occurs due to RX (either packet or ACK received), then the S1CON is cleared.

    In the case of per_test TX function, it does not request ACKs nor receives packets, meaning S1CON is not explicitly cleared in the ISR. But the halRfTransmit checks only the IRQ_TXDONE anyways, so the perhaps it assumes the value in S1CON doesn't matter.

    In the case of light_switch transmit app (switch), ACKs are requested, so the ISR explicitly clears S1CON.

    In both cases, this example code assumes that S1CON really only needs to be explicitly cleared when a packet is received.
    It is probably safer to follow the User Guide and explicitly clear S1CON every time in the ISR regardless if packet is received.

    Thanks,
    Toby