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.

CC2541 receiver

Other Parts Discussed in Thread: CC2541, CC-DEBUGGER, CC2544, SIMPLICITI

Hello,

I use the CC2541 to make a transmitter and a receiver.

I use the kit with the CC-Debugger.

When i send (RFST CMD_TX) my data the PRF_ENDCAUSE is TASK_ENDOK so is suppose my package is sended correctly.

When i want to receive this package with the other CC2541 (RFST CMD_RX) the PRF_ENDCAUSE is TASKERR_PAR. I don't realy find the reason.

This are the settings i programmed to make the receiver.

Does anybody see something wrong ?

Thanks in advance,

============================================================
============================================================


int send_data_length;

//Transmitter only
int data_to_send[8] = {0x40,0x45,0x55,0x60,0x65,0x70,0x75,0x80};
int received_data[16];
int i;


void halSetFrequency(uint16 frequency)
{
    PRF.CHAN.FREQ = frequency-2379;
}


void halRfLoadBLEBroadcastPacketPayload(void)
{
  //Number of bytes effective data
  send_data_length = (sizeof(data_to_send)/sizeof(int));

  //Read data from FIFO
  for(i=0;i<send_data_length+8;i++){
  received_data[i] = RFD;
  }

  return;  
}

============================================================
============================================================


void halRfInitBleBroadcastMode(unsigned short broadcast_channel)
{
  // Clear radio memory (The RAM registers don't have a default value set, must be set manually).
  memset((void*)RFCORE_RAM_PAGE, 0, RFCORE_RAM_PAGE_SZ);
 
  // No timer 2 events sent to LLE
  T2EVTCFG = 0x77;        
 
  PRF.TASK_CONF.MODE              = 0;    // Basic mode, fixed length.
  PRF.TASK_CONF.REPEAT            = 0;    // no repeat  
  PRF.TASK_CONF.START_CONF        = 0;    // Start each receive/transmit immediately
  PRF.TASK_CONF.STOP_CONF         = 0;    // Don't stop on timer 2 event 2.
  PRF.FIFO_CONF.AUTOFLUSH_IGN     = 0;    // Flush duplicate packets
  PRF.FIFO_CONF.AUTOFLUSH_CRC     = 0;    // Flush packets with CRC error
  PRF.FIFO_CONF.AUTOFLUSH_EMPTY   = 0;    // Flush packets with no payload
  PRF.FIFO_CONF.RX_STATUS_CONF    = 0;    // Don't append status information in FIFO
  PRF.FIFO_CONF.RX_ADDR_CONF      = 1;    // Address byte in Rx FIFO
  PRF.FIFO_CONF.TX_ADDR_CONF      = 0;    // Read address from PRF.ADDR_ENTRY[0].ADDRESS
  PRF.PKT_CONF.ADDR_LEN           = 1;    // Address byte.
  PRF.PKT_CONF.AGC_EN             = 0;    // AGC disabled.
  PRF.PKT_CONF.START_TONE         = 0;    // No tone in front of packet.
  PRF.ADDR_ENTRY[0].CONF.REUSE    = 0;    // Don't reuse packet.
 
  TXCTRL    = 0x19;
  TXPOWER   = TXPOWER_0_DBM;      // Set default output power: 0dBm.
  TXFILTCFG = 0x03;               // Set Tx filter bandwidth
  IVCTRL    = 0x1B;
  FRMCTRL0  = 0x40;               // Data goes LSB over the air.
  ADCTEST0  = 0x10;               // Adjust ADC gain.
  MDMCTRL0  = 0x04;               // Set 1 Mbps at 250 kHz deviation.
  MDMCTRL1  = 0x48;               // Correlation threshold
  MDMCTRL2  = 0x00;               // Syncword transmitted LSB to MSB, 1 leading preamble byte,     
  MDMCTRL3  = 0x63;               // Set RSSI mode to peak detect after sync.
  MDMTEST0  = 0x01;
 
   //Address configuration
  PRF.FIFO_CONF.TX_ADDR_CONF = 0;       //Read address from PRF.ADDR_ENTRY[0]
  PRF.ADDR_ENTRY[0].ADDRESS = 0x44;     //Address
  PRF.ADDR_ENTRY[0].CONF.ENA0 = 1;      //Enable address primary sync word
 
  //  Set 32 bit sync word:
  SW_CONF = 0x00;
  SW0 = 0xD6;
  SW1 = 0xBE;
  SW2 = 0x89;
  SW3 = 0x8E;
 
  // Set 3 byte CRC
  PRF_CRC_LEN = 0x03;
  PRF_CRC_INIT[0] = 0x00;
  PRF_CRC_INIT[1] = 0x55;
  PRF_CRC_INIT[2] = 0x55;
  PRF_CRC_INIT[3] = 0x55;
 
  // Set BLE broadcast channel (2402, 2426 or 2480)
  halSetFrequency(broadcast_channel);                    

  // Enable PN7 whitener.
  BSP_P0 = 0x00;
  BSP_P1 = 0x5B;
  BSP_P2 = 0x06;
  BSP_P3 = 0x00;
  BSP_MODE = 0x01;
 
  // Initialization of PN7 whitener in accordance with advertising channel. PRF_W_INIT should be set to 37, 38, or 39 (0x25, 0x26, or 0x27).
  if(broadcast_channel == BLE_BROADCAST_CHANNEL_37)
  {
    PRF_W_INIT = 0x25;  // Init according to BLE channel 37.
  }
  else if(broadcast_channel == BLE_BROADCAST_CHANNEL_37)
  {
    PRF_W_INIT = 0x26;  // Init according to BLE channel 37.
  }
  else if(broadcast_channel == BLE_BROADCAST_CHANNEL_37)
  {
    PRF_W_INIT = 0x27;  // Init according to BLE channel 37.
  }
}


============================================================
============================================================

unsigned char BleBroadcast(void)
{  
  // Clear and update LCD display.     
  halLcdClear();
  halLcdWriteLine(1, "BLE BroadCast");

  // Reset LLE.
  LLECTRL = 0x00;
 
  // Config radio in BLE broadcast mode.
  halRfInitBleBroadcastMode(BLE_BROADCAST_CHANNEL_37);
 
  // Enable the radio.
  LLECTRL = 0x01;

  while(1)  
  {
    // Start receive
    while(RFST != 0);
    RFST = 0x08;
      
    // Wait for TASKDONE    
    while ((RFIRQF1 & RFIRQF1_TASKDONE) != RFIRQF1_TASKDONE);
 
    // If data received read FIFO   
    if(PRF.ENDCAUSE == TASK_ENDOK)    
    {        
      //Get packet data.
      halRfLoadBLEBroadcastPacketPayload();
      
    }

}

  • I used the BLE-broadcast example as a start, i changed the package format a bit for an other application because i don't need the ble packet structure.

    I modified the functions so that is the reason why in the receiver the name broadcast is still there ;-)

  • Hello, 

    If you do not need anything related to BLE, we are currently working on a Proprietary Packet Error Rate test software example that will be posted on web hopefully within the first next months. This will be based on the CC2541EM, but it will be easy to port to other HW modules for the CC2541. I will post an update to this thread when it is released.

    BR. Eirik

  • I got the CC2541 transmitter - receiver working now.Forgot some essential settings like

    PRF.ADDR_ENTRY[0].RXLENGTH = 0x20;

    Thanks for the suggestion, i am also interested in the Proprietary Packet Error Rate test software example for the CC2541.

    Davy

  • Hello Davy, 

    The per test example SW revision B (Which includes support for CC2541 in proprietary mode) should be available on web tomorrow. The current version on web is A, it should be updated within the next 24 hours. (CC254x Proprietary Mode Packet Error Rate Test)

    BR. Eirik

  • Ok,

    thank you

  • Hi,

    I would like to have a question. I configure RF receiver as following:

    halRfConfig(GFSK_2Mbps_500khz, 1, HAL_RF_GAIN_HIGH);
    halRfSetFrequency(2402);
    PRF.ADDR_ENTRY[0].RXLENGTH = 5;
    PRF.TASK_CONF.STOP_CONF= 1; // Stop each receive/transmit on Timer 2 event 2.
    PRF.SEARCH_TIME = 0 ; // Search for ever.
    halRfEnableRadio();
    halMcuWaitMs(100);

    when program runs the instruction

      while ((RFIRQF1 & RFIRQF1_TASKDONE) == 0);

    It pauses here and not run the next instructions.

    Please tell me why

    Thank

  • Hello Minh, 

    Please give me the entire code flow from main until you get to the infinite while loop.

    BR. Eirik

  • Hi BR. Eirik

    Here, this is my code in main program

    /******************************************************************************
    * INCLUDES
    */
    #include "ioCC2544.h"
    #include "per_test.h"
    #include "per_test_timer.h"
    #include "hal_rf_proprietary_per_test.h"
    #include "hal_board.h"
    #include "prop_regs.h"
    #include "simple_hid.h"
    #include "usb_hid.h"


    /***********************************************************************************
    * LOCAL VARIABLES
    */

    // 4 byte variables to store packet sequence number and the number of packets to be sent/received.


    // Char arrays used to store packet payload for ackwoledgements.
    unsigned char __xdata R_rfData[5];

    unsigned char dongle_Receiver(unsigned char* prfData)
    {
    halRfDisableRadio();
    // Setup the radio with the desired test settings.
    halRfInit();
    halRfConfig(GFSK_2Mbps_500khz, 1, HAL_RF_GAIN_HIGH);
    halRfSetFrequency(2402);
    PRF.ADDR_ENTRY[0].RXLENGTH = 5;
    PRF.TASK_CONF.STOP_CONF = 1; // Stop each receive/transmit on Timer 2 event 2.
    PRF.SEARCH_TIME = 0 ; // Search for ever.
    halRfEnableRadio();
    //halMcuWaitMs(200);
    while(1)
    {
    // Start transmitter
    halRfStartRx();
    StartTimer2();

    // Wait for TASKDONE
    while ((RFIRQF1 & RFIRQF1_TASKDONE) == 0);


    // If end cause was TASK_ENDOK then continue as master.
    if(PRF.ENDCAUSE == TASK_ENDOK)
    {
    // Check if ACK with config payload was received.
    if(RFIRQF1 & RFIRQF1_RXOK)
    {
    // Read packet.
    if((R_rfData[0] = RFD) == 5)
    {
    // Read out the test configuration from the RXFIFO.
    R_rfData[1]=RFD;
    R_rfData[2]=RFD;
    R_rfData[3]=RFD;
    R_rfData[4]=RFD;
    //copy R_rfData ->prfData
    memcpy(prfData,R_rfData,R_rfData[0]);
    // Clear interrupt.
    RFIRQF1 = 0;
    }
    // Reset Rx FIFO
    while (RFST != 0);
    RFST = CMD_RXFIFO_RESET;
    return RUN_SUCCESS;

    }
    }
    // Received no ACK.
    else if(PRF.ENDCAUSE == TASK_RXTIMEOUT)
    {
    HAL_LED_CLR_2();
    return RUN_ERROR;
    }
    // Clear interrupt and continue as master.
    RFIRQF1 = 0;
    // Set to a undefined value in enum type end cause.
    PRF.ENDCAUSE = TASK_UNDEF;

    // Toggle green LED for every 10 sent packets.

    }
    }
    int main(void)
    {
    uint8 *data;
    // Main auto variables.

    // Initialize Clock Source (32 Mhz Xtal), global interrupt (EA=1), I/O ports and pheripherals(LCD).
    halBoardInit();

    // Turn on LED1 ( green )
    HAL_LED_SET_2();

    // CC2544 Dongle is always in master mode
    while(1)
    {
    dongle_Receiver(data);
    }
    }

    Please read it.

    Thank

    Tri

  • As I understand your example shows how to transmit data at high speed without BLE. Could you help me? I learned to program in IAR SPI interface(4Mhz) for my device. I need to transfer twice a second block of 30 KB of data to RF. How to leave only the lowest layer of programming for CC2541?

  • Hello Igor, 

    Could you start a new thread in the Low Power RF Proprietary Software & SimpliciTI Forum?

    Also could you elaborate a bit more about what you mean by: "leave only the lowest layer of programming for CC2541?"

    Best Regards, Eirik

  • Hello Tri,

    As far as i can see you never set a timeout value for timer2:

    // Set timeout in ms for radio. 
    SetRadioTimeout(100);

    The statement:

    // Wait for TASKDONE 
    while ((RFIRQF1 & RFIRQF1_TASKDONE) == 0);

    Will always be true unless you receive a packet which causes the TASKDONE interrupt to be raised or if you receive a Timer2 event 2 trigger which also in this case will cause a TASKDONE interrupt to occur.

    Did that solve it?

    BR. Eirik

  • Hi,

    Can you please tell me which example, the BLE-broadcast, you are referring to? I have been looking for it without result. 

    Thanks