I am currently working on a transceiver project, which works with the MSP430F5438 micro controller and the CC1200 RF chip. I used it for RX in 145MHZ, and
my Tx function looks like this:
void runRX(void) { uint8 rxBytes; uint8 marcState; uint8 rxBuffer[128] = {0}; // Connect ISR function to GPIO2 ioPinIntRegister(IO_PIN_PORT_2, GPIO3, &radioRxISR); // Interrupt on falling edge ioPinIntTypeSet(IO_PIN_PORT_2, GPIO3, IO_PIN_FALLING_EDGE); // Clear ISR flag ioPinIntClear(IO_PIN_PORT_2, GPIO3); // Enable interrupt ioPinIntEnable(IO_PIN_PORT_2, GPIO3); // Set radio in RX trxSpiCmdStrobe(CC1200_SRX); ioOperate(); // Infinite loop while(1) { // Wait for packet received interrupt if(packetSemaphore == ISR_ACTION_REQUIRED) { // Read number of bytes in RX FIFO CC1200SpiReadReg(CC1200_NUM_RXBYTES, &rxBytes, 1); // Check that we have bytes in FIFO if(rxBytes != 0) { // Read MARCSTATE to check for RX FIFO error CC1200SpiReadReg(CC1200_MARCSTATE, &marcState, 1); // Mask out MARCSTATE bits and check if we have a RX FIFO error if((marcState & 0x1F) == RX_FIFO_ERROR) { // Flush RX FIFO trxSpiCmdStrobe(CC1200_SFRX); } else { // Read n bytes from RX FIFO CC1200SpiReadRxFifo(rxBuffer, rxBytes); // Check CRC ok (CRC_OK: bit7 in second status byte) // This assumes status bytes are appended in RX_FIFO // (PKT_CFG1.APPEND_STATUS = 1) // If CRC is disabled the CRC_OK field will read 1 if(rxBuffer[rxBytes - 1] & 0x80) { // Update packet counter packetCounter++; } } } // Reset packet semaphore packetSemaphore = ISR_IDLE; // Set radio back in RX trxSpiCmdStrobe(CC1200_SRX); } } }
The problem I am having is that the code gets stuck at the "if ( packetSemaphore == ISR_ACTION_REQUIRED)" line, due to the flag never changing.
Has anyone give me some suggestions?