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.