How manually switch between ATmega128RFA1 antennas?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In my HW project (based on Dresden Elektronik module deRFmega128-22M12, LwMesh) is needed to switch RF activity to Antenna 1 only, RxDiv must be off.
I try:

TRX_CTRL_1_REG_s.paExtEn = 1;
  
ANT_DIV_REG_s.antDivEn = 0;
ANT_DIV_REG_s.antExtSwEn = 1;
ANT_DIV_REG_s.antCtrl = 1;

Independent on the content of register bits ANT_CTRL, ANT_SEL bit is constant 0, DIG1/PG1 is zero too and RF power not switched from Antenna 0 to Antenna 1.

I forgot to set something, or do something wrong?

Last Edited: Fri. Oct 16, 2015 - 02:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"ANT_DIV_REG_s.antCtrl = 1" is "Antenna 1: DIG1=L, DIG2=H", so DIG1 is supposed to be low with this setting.

Where do you put this code? What happens if you set "antCtrl = 2"?

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I put this code in LwMesh appInit()
in both ANT:CTRL variations ANT_SEL is 0

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try to put this in the PHY_Init(). Radio might be in the wrong state when you are writing.

NOTE: I no longer actively read this forum. Please ask your question on www.eevblog.com/forum if you want my answer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Alex, Thank you, it works!
Only moving to PHY_Init() was needed:

void PHY_Init(void)
{
  TRXPR_REG_s.trxrst = 1;

  phyTrxSetState(TRX_CMD_TRX_OFF);

  CSMA_SEED_1_REG_s.aackSetPd = 1;
  CSMA_SEED_1_REG_s.aackDisAck = 0;

  IRQ_STATUS_REG = IRQ_STATUS_CLEAR_VALUE;
  IRQ_MASK_REG_s.rxEndEn = 1;
  IRQ_MASK_REG_s.txEndEn = 1;

  TRX_CTRL_2_REG_s.rxSafeMode = 1;

// added code  
  TRX_CTRL_1_REG_s.paExtEn = 1;
  
  ANT_DIV_REG_s.antDivEn = 0;
  ANT_DIV_REG_s.antExtSwEn = 1;
  ANT_DIV_REG_s.antCtrl = 1;
// end added code

#ifdef PHY_ENABLE_RANDOM_NUMBER_GENERATOR
  CSMA_SEED_0_REG = (uint8_t)phyGetRandomNumber();
#else
  CSMA_SEED_0_REG = 0x11;
#endif

  phyIb.request = PHY_REQ_NONE;
  phyIb.rx = false;
  phyState = PHY_STATE_IDLE;
}