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();
}