Other Parts Discussed in Thread: CC2540
I saw people struggling using the CC2540 spi slave mode, here is what I found:
1. The labling for Port 0 SPI interface in the CC2540 MiniDK schematic (REV. 1.1.0) is wrong. The P0_2 should be MISO (output from the CC2540 for spi slave mode) and P0_3 should be MOSI accourding to the CC2540 manual.
2. The spi initialization code :
{
PERCFG &= ~0x01; //Setup USART 0 SPI at alternate location 0
P2DIR &=~0xC0;
P0SEL |= 0x3C; // Peripheral function on SCK, MISO and MOSI (P0.2,3,5) and CS p0.4
U0CSR = 0x20;///SPI slave mode
U0GCR = 0xA0;
U0GCR |= 0x12;
U0BAUD = 0; //8MHz
TCON=~0x8; //clear URX0IF flag
IEN0|=0x4; //USART0RX IE enable
U0CSR &=~0x4;
}
3. SPI RX interrupt handler:
volatile uint8 SPI_Rxbuffer;
HAL_ISR_FUNCTION( spiPoart0Isr, URX0_VECTOR )
{
SPI_Rxbuffer=U0DBUF;
TCON=~0x8; //clear URX0IF flag
}
Don't have time to look at SPI DMA transfer yet, hope it's useful for people here.