Hello everybody.
I am working with the CC1125 transceiver, connected via SPI with an Atmel microcontroller (ATxmega256).
Atmel provides source files to access the CC1125 registers and configure them. The file I use is similar to this one. In my case, in the function trx_config I write to the registers:
/** * @brief Configures the transceiver * * This function is called to configure the transceiver after reset. */ static void trx_config(void) { /* * Configuration of CSMA seed is done later in function trx_config_csma() * after the generation of a proper random seed for function rand(); */ pal_trx_reg_write(IOCFG3,0x06); pal_trx_reg_write(IOCFG2,0x0F); pal_trx_reg_write(IOCFG1,0xB0); pal_trx_reg_write(IOCFG0,0x06); pal_trx_reg_write(SYNC_CFG1,0x0B); pal_trx_reg_write(MODCFG_DEV_E,0x02); pal_trx_reg_write(DEVIATION_M,0xA3); (continue...)
Function pal_trx_reg_write is located in this file and it reproduced here:
/** * @brief Writes data into a transceiver register * * This function writes a value into transceiver register. * * @param addr Address of the trx register * @param data Data to be written to trx register * */ void pal_trx_reg_write(uint8_t addr, uint8_t data) { ENTER_TRX_REGION(); #ifdef NON_BLOCKING_SPI while (spi_state != SPI_IDLE) { /* wait until SPI gets available */ } #endif /* Prepare the command byte */ addr |= WRITE_ACCESS_COMMAND; /* Start SPI transaction by pulling SEL low */ SS_LOW(); /* Send the Read command byte */ SPDR = addr; SPI_WAIT(); /* Write the byte in the transceiver data register */ SPDR = data; SPI_WAIT(); /* Stop the SPI transaction by setting SEL high */ SS_HIGH(); LEAVE_TRX_REGION(); }
The initialization of registers is OK just after transceiver reset. But if I want to change the registers values later (e.g. carrier frequency), the SPI write operation fails. That is to say, I write a certain value, then read the register and the value is different (wrong).
Thanks in advance for your help!