Other Parts Discussed in Thread: CC1101, SIMPLICITI, EK-EVALBOT, CC1121
Hi
I am trying to interface CC1101 RF chip with LM4F232 controllers. I am using SSI 0 SPI channel of LM4F232 to configure RF chip.
Pin connection of CC1101_DK_Em433 (eval board) to
SCLK -> SSIOCLK
S1->SSIOTX
S0-> SIORX
CSN1->SSI0FSS
Configured SPI channel to communicate at 10khz.
My queries are
1) Which SPI format should I use to communicate with CC1101.
SSI_FRF_MOTO_MODE_0
SSI_FRF_MOTO_MODE_1
SSI_FRF_MOTO_MODE_2
SSI_FRF_MOTO_MODE_3
SSI_FRF_TI
SSI_FRF_NMW
2) When I try to write and read back CC1101 registers I always get back 0x0F (on any register read). Can you please look in to my code and help me to find out missing steps
void InitializeRfSpiChannel(void)
{
UINT32 dummy;
// The SSI0 peripheral must be enabled for use.
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//Give some delay to allow the peripheral to start up
MAP_SysCtlDelay(2);
// Configure the pin muxing for SSI0 functions on port A2, A3, A4, and A5.
// This step is not necessary if your part does not support pin muxing.
// TODO: change this to select the port/pin you are using.
MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
MAP_GPIOPinConfigure(GPIO_PA4_SSI0RX);
MAP_GPIOPinConfigure(GPIO_PA5_SSI0TX);
//Give some delay to allow the peripheral to start up
MAP_SysCtlDelay(2);
//
// Configure the GPIO settings for the SSI pins.
MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE,
GPIO_PIN_2 | GPIO_PIN_3 |
GPIO_PIN_4 | GPIO_PIN_5);
//set clock source
MAP_SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_SYSTEM);
MAP_SSIConfigSetExpClk(SSI0_BASE, SystemClockFreq, SSI_FRF_MOTO_MODE_0,
SSI_MODE_MASTER, 10000, 8);
//disable SPI interrupts we are not going to use interrupts
MAP_SSIIntDisable(SSI0_BASE, SSI_TXFF | SSI_RXFF | SSI_RXOR | SSI_RXTO);
//disable DMA
MAP_SSIDMADisable(SSI0_BASE, SSI_DMA_RX | SSI_DMA_TX);
// Enable the SSI0 module.
SSIEnable(SSI0_BASE);
while(SSIDataGetNonBlocking(SSI0_BASE, &dummy))
{
}
}
void WriteDataToRfSpiChannel(UINT8 address, UINT8 data)
{
UINT32 tempData;
// write address
MAP_SSIDataPut(SSI0_BASE, (UINT32)((UINT32)address & (UINT32)0x000000FF));
// Wait until SSI0 is done transferring all the data in the transmit FIFO.
while(MAP_SSIBusy(SSI0_BASE))
{
}
// read to clear
MAP_SSIDataGet(SSI0_BASE, &tempData);
// write data
MAP_SSIDataPut(SSI0_BASE, (UINT32)((UINT32)data & (UINT32)0x000000FF));
// Wait until SSI0 is done transferring all the data in the transmit FIFO.
while(MAP_SSIBusy(SSI0_BASE))
{
}
// read to clear
MAP_SSIDataGet(SSI0_BASE, &tempData);
}
UINT8 ReadDataFromRfSpiChannel(UINT8 address)
{
UINT32 tempData;
address = (address & 0x3F)|0x80;
// write address
MAP_SSIDataPut(SSI0_BASE, (UINT32)((UINT32)address & (UINT32)0x000000FF));
// Wait until SSI0 is done transferring all the data in the transmit FIFO.
while(MAP_SSIBusy(SSI0_BASE))
{
}
// read to clear
MAP_SSIDataGet(SSI0_BASE, &tempData);
// write dummy char char to get data from slave
MAP_SSIDataPut(SSI0_BASE, (UINT32)((UINT32)0x00000000 & (UINT32)0x000000FF));
// Wait until SSI0 is done transferring all the data in the transmit FIFO.
while(MAP_SSIBusy(SSI0_BASE))
{
}
// now read actual data from received from slave
MAP_SSIDataGet(SSI0_BASE, &tempData);
return (tempData & 0x000000FF);
}