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.

AFE032 switch from Tx to Rx

Other Parts Discussed in Thread: AFE032

Hi People,

I'm using AFE032 chip and need to switch from transmit mode to receiver mode at times.

I have implemented one way and that does not work but I have checked the registers and they seem to have the expected values.

The way I test if it worked or not is by checking the RX_Flag and TX_FLAG. 

Below function works correctly:

// Call this function when the chip is already in a TX mode and needs to be changed to RX mode
void afe032_Tx2Rx(void)
{
       init_afe032();
       HAL_afe032_rxEnable();
}

void init_afe032(void)
{
	UINT16 afeDigFiltSelect;
	UINT16 preClkScale,postClkScale,lpfBand, hpfBand, notchLutSelect;
	UINT16 temp = 0;

	 memset(&HAL_afe032_reg_s, 0, sizeof(HAL_afe032_reg_t));

	// software reset
	HAL_afe032_softReset();

	//CQ1796 : Enable all three Zero crossing
	HAL_afe032_reg_s.vref.bits.ZC_DETECT = 7;

	HAL_afe032_biasEnable(); // enables PA_NRF, TX_RX_NRF, DAC_NRF

	afeDigFiltSelect =  0x0; //include IIR and notch
	preClkScale = 3;
	postClkScale = 0;
	lpfBand = 3;			//490kHz
	hpfBand = 0;			//35kHz
	notchLutSelect = 0;
	HAL_afe032_regWrite(HAL_AFE032_CTL_REG, afeDigFiltSelect);
	HAL_afe032_dacClkScale(preClkScale,postClkScale);	// sets internal DAC clock pre and post scalers

	HAL_afe032_reg_s.band_cfg.bits.swdac = 1;
	HAL_afe032_regWrite(HAL_AFE032_HPF_LPF_CFG_REG, HAL_afe032_reg_s.band_cfg.all); // set Enable assist

	HAL_afe032_bandSelect(lpfBand,hpfBand);		// set tx lpf and hpf bands to 35k - 490k

	HAL_afe032_farrowOffset();	// sets offsets to default values

	HAL_afe032_regWrite(HAL_AFE032_PA_CURRENT_CFG_REG, 0x00C0); // PA Current Limit - 25 mA, current limit = 1.25A

	HAL_afe032_notchSetup(notchLutSelect);
	HAL_afe032_iirSetup(1); //FCC band

	/* RX PGA gain 0dB */
	HAL_afe032_writeRxGain(0);	// PGA1 = 0.125, PGA2 = 0

	// TX PGA gain (0 = 1.15, 1 = 2.3, 2 = 3.25, 3 =  4.6)
	HAL_afe032_writeTxGain(0);

	// Enable LPF, HPF
	HAL_afe032_reg_s.enable.bits.LPF = 1;
//	HAL_afe032_reg_s.enable.bits.HPF = 1;
	HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);

	HAL_afe032_reg_s.enable.bits.DAC = 1;
	HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);

	//  wait 2s
	DELAY_US(2000000);
}

void HAL_afe032_rxEnable(void)
{
 UINT16 intStatus, status;
 UINT16 temp;

 HAL_afe032_reg_s.rx_pga.all = 0x0032;		// RXPGA1 = 1V RXPGA2 = 4
 HAL_afe032_regWrite(HAL_AFE032_RXPGA_CFG_REG, HAL_afe032_reg_s.rx_pga.all);

 HAL_afe032_reg_s.rx_tx_ctl.bits.RX = 1;
 HAL_afe032_reg_s.rx_tx_ctl.bits.TX = 0;
 HAL_afe032_regWrite(HAL_AFE032_RX_TX_CTL_REG, HAL_afe032_reg_s.rx_tx_ctl.all);

 HAL_afe032_reg_s.enable.bits.LPF = 1;
 HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);
 HAL_afe032_reg_s.enable.bits.HPF = 0;
 HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);

 temp = HAL_afe032_regRead(HAL_AFE032_ENABLE_REG);

 while(AFE032_RX_FLAG); // wait for rx flag to go low
 while(!AFE032_TX_FLAG); // wait for tx flag to go high
}

I don't want to use the method above because AFE032 chip has been initialised once already so I should be able to just change some parts of it. Below function is not working:

void afe032switch_TX2RX(void)
{
      HAL_afe032_TxStop();
      HAL_afe032_rxEnable();
}

void HAL_afe032_TxStop(void)
{
	HAL_afe032_reg_s.pa_curr_cfg.bits.PA_CURR_CTL = 3;  // PA IQ Curr = 25 mA
	HAL_afe032_regWrite(HAL_AFE032_PA_CURRENT_CFG_REG,HAL_afe032_reg_s.pa_curr_cfg.all);
// Disable PA
	HAL_afe032_reg_s.enable.bits.PA_OUT = 0;
	HAL_afe032_reg_s.enable.bits.PA = 0;
	HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);

	HAL_afe032_reg_s.pa_curr_cfg.bits.ENPAIQN = 0;
	HAL_afe032_reg_s.pa_curr_cfg.bits.ENPAIQP = 0;
	HAL_afe032_regWrite(HAL_AFE032_PA_CURRENT_CFG_REG,HAL_afe032_reg_s.pa_curr_cfg.all);

	HAL_afe032_reg_s.rx_tx_ctl.bits.ENPCOMP = 0;
	HAL_afe032_reg_s.rx_tx_ctl.bits.ENNCOMP = 0;
	HAL_afe032_regWrite(HAL_AFE032_RX_TX_CTL_REG, HAL_afe032_reg_s.rx_tx_ctl.all);

	HAL_afe032_reg_s.pa_curr_cfg.bits.PA_CURR_CTL = 0;  // PA IQ Curr = 55 mA
	HAL_afe032_regWrite(HAL_AFE032_PA_CURRENT_CFG_REG,HAL_afe032_reg_s.pa_curr_cfg.all);

	HAL_afe032_writeTxGain(0); // TX PGA gain 1.1

// Disable TX
	HAL_afe032_reg_s.rx_tx_ctl.bits.TX = 0;
	HAL_afe032_regWrite(HAL_AFE032_RX_TX_CTL_REG, HAL_afe032_reg_s.rx_tx_ctl.all);
	DELAY_US(50); // tx-rx switch settling time
}

void HAL_afe032_rxEnable(void)
{
 UINT16 intStatus, status;
 UINT16 temp;

 HAL_afe032_reg_s.rx_pga.all = 0x0032;		// RXPGA1 = 1V RXPGA2 = 4
 HAL_afe032_regWrite(HAL_AFE032_RXPGA_CFG_REG, HAL_afe032_reg_s.rx_pga.all);

 HAL_afe032_reg_s.rx_tx_ctl.bits.RX = 1;
 HAL_afe032_reg_s.rx_tx_ctl.bits.TX = 0;
 HAL_afe032_regWrite(HAL_AFE032_RX_TX_CTL_REG, HAL_afe032_reg_s.rx_tx_ctl.all);

 HAL_afe032_reg_s.enable.bits.LPF = 1;
 HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);
 HAL_afe032_reg_s.enable.bits.HPF = 0;
 HAL_afe032_regWrite(HAL_AFE032_ENABLE_REG, HAL_afe032_reg_s.enable.all);

 temp = HAL_afe032_regRead(HAL_AFE032_ENABLE_REG);

 while(AFE032_RX_FLAG); // wait for rx flag to go low         <----- this is where it gets stuck
 while(!AFE032_TX_FLAG); // wait for tx flag to go high
}

I have checked the content of HAL_afe032_reg_s variable and it contains the same values at the end of both functions.

Can someone please let me know what I need to do to switch from transmit mode to receiver mode??

Thanks!

Ayaka