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.

CC1200 Example code ISR

Other Parts Discussed in Thread: MSP430F5438A, MSP430F5510, CC1200

Hello everyone,

I am currently working on a transceiver project, which works with the MSP430F5510 micro controller and the CC1200 RF chip. My code is based on the provided example code for the CC1200. I am fairly new to embedded programming and I only have Code Composer Studio v5 at my disposal. I had to therefore adapt the example code, as I could only find it as a ready project for IAR and it was written for another micro controller- MSP430F5438A.

The problem I am currently stuck at is related to the interrupt routine in the example code. Currently my Tx function looks like this:

static void runTX(void) {

  // Initialize packet buffer of size PKTLEN + 1
  uint8 txBuffer[PKTLEN+1] = {0};
  uint8 txBytesDataArray[3] = {1, 1, 1};
  rfStatus_t testState;
  int i,j=0;

  // Connect ISR function to GPIO2
  ioPinIntRegister(IO_PIN_PORT_1, GPIO2, &radioTxISR);

  // Interrupt on falling edge
  ioPinIntTypeSet(IO_PIN_PORT_1, GPIO2, IO_PIN_FALLING_EDGE);

  // Enable interrupt
  ioPinIntEnable(IO_PIN_PORT_1, GPIO2);

  // Infinite loop
 while(TRUE) {

        // Create a random packet with PKTLEN + 2 byte packet
        // counter + n x random bytes
        createPacket(txBuffer);

        // Write packet to TX FIFO
        cc120xSpiWriteTxFifo(txBuffer, sizeof(txBuffer));
        cc120xSpiReadReg(CC120X_NUM_TXBYTES, &txBytesDataArray[0], 2);

        // Strobe TX to send packet
        trxSpiCmdStrobe(CC120X_STX);

        SET_LED_GREEN(1)
        //for(i=0;i<5000;i++){
        //}

        // Update packet counter
        packetCounter++;

        // Wait for interrupt that packet has been sent.
        // Assumes the GPIO connected to the radioRxTxISR function is set
        // to GPIOx_CFG = 0x06)
        while(packetSemaphore != ISR_ACTION_REQUIRED);

        SET_LED_GREEN(0)
        //for(j=0;j<5000;j++){ _nop();
        //}
        // Clear semaphore flag
        packetSemaphore = ISR_IDLE;

    }
  }

The problem I am having is that the code gets stuck at the "while ( packetSemaphore != ISR_ACTION_REQUIRED)" line, due to the flag never changing. From the setting up of the interrupt routine above the infinite "while(TRUE)" loop, I understand that the ISR should get initiated on the falling edge, when a signal is received at the GPIO2 pin.

This is currently happening only once, the code sends one packet and then the ISR never activates again and gets stuck. The connections seem to be fine, as the pulse can be seen on an oscilloscope. If I remove it and introduce delays with the empty "for" loops, the Tx functionality works fine, but the Rx code has the expected problem that, when it's in a delay loop it misses parts of packets and therefore this approach is not suitable.

Out of curiosity I tried leaving both the empty for loops and the while loop waiting for the interrupt and the device sends twice and then goes into the infinite waiting. This means that the function's logically probably fine, it may be a timing issue, due to the code being initially written for the MSP430F5438a.

Has anyone encountered a similar problem? Any other tips would also be greatly appreciated.

  • Hi

    Usually when you only get one interrupt, it is caused by the radio goes in to an error state (TXFIFO_OVERFLOW or UNDERFLOW) after the first packet, halting the packet transmission. Have you checked that the radio is in IDLE after the first semaphore is set?

    Also check that the interrupt on the pin is still enabled for the second transmission and is not been disabled between the two transmissions.

  • Hi Martin,

    Thanks for the quick response. The device does go into IDLE after the first semaphore.


    On the second point, I'm not completely sure. Currently, I'm using GPIO 2 for the ISR, it is on port 1, pin 2. Therefore P1IFG2 gets set to 1 when needed, P1IE2 though, stays at 0. I'm guessing this means it's disabled? Also if it is, how should I enable it ?

    Kind Regards,

    Lachezar

  • Hi

    If you check P1IE2 before the first transmission it should be set to 1. It sounds to me that at some point during the first transmission P1IE2 is set to 0. Be sure that P1IE2 is set to 1 (enabled) before any transmission.

    In your code this should happen in the ioPinIntEnable function

  • Hi,

    You were right, it was the interrupt being disabled. Oddly enough, the pin was not enabled at all in the first place, so it turned out that my definition of GPIO2 was wrong.

    It works well now, thanks a lot for the help and the quick responses

    Kind Regards

    Lachezar

  • Hi

    That's good news. Good luck continuing forward!