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 SPI

Hi,

I use sensor tag project and added to him SPI.

i send packet and some times one byte have not arrived.

it is occurs only when the sensor tag transmit data to iPhone APP.

i tested the SPI without BLE communication and it is send all the data well,without errors.

Why it is occurs ?

This is my SPI configuration:

* Setup I/O ports
*
* Port 1_X and pins used USART0 operating in SPI-mode are
* MISO (MI): P1_4 RX(6)
* MOSI (MO): P1_5 TX(1)
* SSN (SS) : P1_2 CS(2)
* SCK (C) : P1_3 RT(3)
*
* These pins can be set to function as peripheral I/O so that they
* can be used by USART0 SPI.
*/

// Configure USART0 for Alternative 2 => Port P0 (PERCFG.U0CFG = 1)

PERCFG = 0x01;

P2SEL &=0x07; // Set priority for USART0

// Give priority to USART 0 over Timer 1 for port 0 pins

P2DIR &= ~P2DIR_PRIPO;
P2DIR |= HAL_SPI_PRIPO;

// Set pins 2, 3, 4 and 5 as peripheral I/O.
//P1SEL = P1_2 | P1_3 | P1_5 | P1_4; // P1SEL= 0x3C
P1SEL = 0x3C;

/***************************************************************************
* Setup interrupt
*/

// Clear CPU interrupt flag for USART0 RX (TCON.URX0IF)
URX0IF = 0;

// Set individual interrupt enable bit in the peripherals SFR
// Not any.

// Enable interrupt from USART0 RX by setting [IEN0.URX0IE=1]
URX0IE = 1;


/***************************************************************************
* Configure SPI
*/

// Set USART to SPI mode and Slave mode
U0CSR = U0CSR | U0CSR_MODE | U0CSR_SLAVE;


U0BAUD = SPI_BAUD_M;
U0GCR = (U0GCR & ~(U0GCR_BAUD_E | U0GCR_CPOL | U0GCR_CPHA | U0GCR_ORDER ))
| SPI_BAUD_E| U0GCR_ORDER ;

------------------------------------

SPI ISR

HAL_ISR_FUNCTION(spi0rx_isr,URX0_VECTOR)
{
HAL_ENTER_ISR();

#ifdef POWER_SAVING
 CLEAR_SLEEP_MODE();
 osal_pwrmgr_task_state(Hal_TaskID, PWRMGR_HOLD);
#endif

spiRxBuffer[spiRxIndex++] = U0DBUF;


TCON &= ~0x08;


HAL_EXIT_ISR();

}

  • Hello,

    CC254X halts the CPU when RF is active in order to keep peak current down, and this can delay ISR handling. You can disable the halt on rf with HCI command disablehaltonrf command.   

    BR,

    -Greg

  • Hi,

    HCI_EXT_HaltDuringRfCmd(HCI_EXT_HALT_DURING_RF_DISABLE); 

    I do it in Function : 

    SensorTag_Init( uint8 task_id )

    {

    ......

    //disable halt during RF (needed for UART / SPI)
    HCI_EXT_HaltDuringRfCmd(HCI_EXT_HALT_DURING_RF_DISABLE);

    ......

    }

    Something else?

  • Hi,

    Is it safe to assume that if you call the osal power manager to hold upon entering the SPI ISR, that it is then safe to return back to power manger conserve before exiting ISR?

    For example:

    #ifdef POWER_SAVING

    CLEAR_SLEEP_MODE();

    osal_pwrmgr_task_state(PWRMGR_HOLD) upon entering the ISR, that you can safely call

    #endif

    //READ BUFFER & CLEAR FLAG

    #ifdef POWER_SAVING

    osal_pwrmgr_task_state(PWRMGR_CONSERVE)

    //EXIT ISR