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.

need help in programming the radio of cc2510

Other Parts Discussed in Thread: SIMPLICITI, CC2510, TEST2

Hi every one,

I am working on wireless connectivity project using simpliciTI. I am having the CC2510  mini development board with me. Now i am familiar with the microcontroller which is embedded in it. But i am getting problems in programming thr radio that is present in the chip.

When i am writing code for continuous transmissioin of a character using ISR when RFTXRXIF is enabled it is not working. The below is the code i have written to transmitt the character continuously. The problem with the code is the ISR function is not executing when the RFTXRXIF interrup is asserting.

Suggest the suitable solution to it.

#include<ioCC2510.h>
#include<ioCCxx10_bitdef.h>
void tdelay(unsigned int );
volatile unsigned char ch;
void main(void)
{
    CLKCON=0x00;
    SLEEP &= ~SLEEP_OSC_PD;
    while( !(SLEEP & SLEEP_XOSC_S) );
    CLKCON = (CLKCON & ~(CLKCON_CLKSPD | CLKCON_OSC)) | CLKSPD_DIV_1;
    while (CLKCON & CLKCON_OSC);
    SLEEP |= SLEEP_OSC_PD;
    RFTXRXIE=1;
  /* RF settings SoC */
FSCTRL1   =     0x0A;       // Frequency Synthesizer Control
FSCTRL0   =     0x00;       // Frequency Synthesizer Control
FREQ2     =     0x5D;       // Frequency Control Word, High Byte
FREQ1     =     0x44;       // Frequency Control Word, Middle Byte
FREQ0     =     0xEC;       // Frequency Control Word, Low Byte
MDMCFG4   =     0x28;       // Modem configuration
MDMCFG3   =     0x83;       // Modem Configuration
MDMCFG2   =     0x03;       // Modem Configuration
MDMCFG1   =     0x23;       // Modem Configuration
MDMCFG0   =     0x3B;       // Modem Configuration
CHANNR    =     0x00;       // Channel Number
DEVIATN   =     0x00;       // Modem Deviation Setting
FREND1    =     0xB6;       // Front End RX Configuration
FREND0    =     0x10;       // Front End TX Configuration
MCSM0     =     0x14;       // Main Radio Control State Machine Configuration
FOCCFG    =     0x1D;       // Frequency Offset Compensation Configuration
BSCFG     =     0x1C;       // Bit Synchronization Configuration
AGCCTRL2  =     0xC7;       // AGC Control 
AGCCTRL1  =     0x00;       // AGC Control 
AGCCTRL0  =     0xB2;       // AGC Control 
FSCAL3    =     0xA9;       // Frequency Synthesizer Calibration
FSCAL2    =     0x0A;       // Frequency Synthesizer Calibration
FSCAL1    =     0x00;       // Frequency Synthesizer Calibration
FSCAL0    =     0x11;       // Frequency Synthesizer Calibration
TEST2     =     0x88;       // Various Test Settings
TEST1     =     0x31;       // Various Test Settings
TEST0     =     0x09;       // Various Test Settings
PA_TABLE0 =     0xFE;       // PA Power Setting
PKTCTRL1  =     0x04;       // Packet Automation Control
PKTCTRL0  =     0x05;       // Packet Automation Control
ADDR      =     0x00;       // Device Address
PKTLEN    =     0xFF;       // Packet Length 
MCSM1     =     0x32;
RFIM=0x80;
RFST=RFST_SCAL;
RFST=RFST_STX;
  while(1)
  {
    //RFTXRXIF=0;
     RFD='s';
     while(RFTXRXIF==0);
    //RFTXRXIF=0;
 
     while ((MARCSTATE & MARCSTATE_MARC_STATE) != MARC_STATE_TX)
     {
         RFST=RFST_SIDLE;
         RFST=RFST_STX;
 
     }
  }

}


_Pragma ("vector=RFTXRX_VECTOR") __interrupt void TX_UNFLW_INTR(void);
_Pragma ("vector=RFTXRX_VECTOR") __interrupt void TX_UNFLW_INTR (void)
{
  RFTXRXIF=0;
}

Suggest the suitable solution to it.

Regards

N S S Sandeep

  • Hi,

    I am not sure if this is the reason your code is not working, but you will need to enable global interrupt. I can not see in your code that this is done. You can do this by setting IEN0.EA=1 (See also section 10.5.1 in the CC2510 datasheet).

    Regards,

    Bjørn

  • Hi Bjørn,

    Thanks for replying. In the code i have enabled the interrupts which are only usefull. Here i have written ISR only for RFTXRXIF (RFTXRXIE=1) and the TX underflow interrupt which is enabled through the RFIM (rfim=0X80) register. Also i have tried to enable all the interrupts as you said using IE0.EA=1. But it is not working. 

    Thanks & Regards

    N S S Sandeep

  • Hi,

    Yes, you will have to both enable global interrupts (IEN0.EA=1) and enable the individual interrupts that you are interested in using (e.g for RFTXRX interrupt IEN0.RFTXRXIE=1).

    Regards,

    Bjørn

  • Hi,

    I have enabled both and checked. Then also code is not working. Have you seen the way i have written the ISR. is that the correct way?

    Regards

    N S S Sandeep

     

  • Hi,

    The ISR itself looks ok, but be sure that you only strobe STX once for each time you write to the FIFO (otherwise you may risk the TX underflow condition). I would not have the strobe commands in a while loop like this, but rather make sure that IDLE and STX is only done once for each time you want to send.

    I would also recommend using the IAR debugger to check how far in the code you reach, and to check if the interrupt handler is called when the corresponding interrupt flag is set.

    If you are using SimpliciTI you should not need to write this code though as you can achieve the same with function calls in SimpliciTI. If you want something more basic you can use the MRFI layer directly (SimpliciTI is built on top of MRFI).

    Regards,

    Bjørn

  • Hi Bjørn,

    That is what my problem. I am using the debugger and checking the flow of the program. Whenever i am writing the character 's' to the RFD the Transmitter underflow flag is becoming '1'. But the ISR witten for the Transmitter underflow is not executing. Instead it is proceding to the next line and the Transmitter underflow condition is not clearing at all. Why i am geting the transmitter underflow condition?

    Thanks & Regards,

    N S S Sandeep

  • Hi,

    You can send packets in either fixed length mode or variable length mode. This is controlled with PKTCTRL0.LENGTH_CONFIG. From your code it looks like you are using variable length mode. Then the radio expects the first byte in the TX FIFO to be the length of your packet (See section 13.8.4 in datasheet). You will need to first write the payload to the fifo and then at last the length byte (length of payload including an optional address byte). I think this may explain why you are always getting TX FIFO underflow.

    Optionally you can use fixed packet length mode. Then the packet length is configured with the register PKT_LEN, and you need to write exactly the same number of payload bytes to the TX FIFO as the PKT_LEN register is set. No length byte shall be written to the fifo in fixed length mode.

    Regards,

    Bjørn

  • Hi,

    Thank you. I didnot check the packet control registers. But when the underflow interrupt is occuring the control must be shifted to the ISR. what might be the reason that my ISR is not implemented even though an underflow or RFTXRX interrupts are occuring?

    Thanks & Regards

    N S S Sandeep 

  • Hi,

    The only thing i can see missing from the code that you pasted in is to enable the global interrupts with IEN0.EA=1. When this is done I would expect the code execution to jump to your ISR if  RFTXRXIF is set.

    Regards,

    Bjørn

  • Hi Bjørn,

    It is working. Thank you for helping. The thing is the interrupt is executing but the debugger is not showing visually. That is it is not showing visually that the program flow is shifted to the ISR that i have written. But the lines inside my ISR are executing. Once again thank you for your help.

    Thanks & Regards

    N S S Sandeep