There are two main steps to configure
the AFE device. First, ensure that the GPIOs are configured correctly. On the AFE
device, two main GPIOs are set up: DAC Mode Select and System Shutdown. Both of
these pins are pulled low. All other GPIOs connected can also be pulled low.
The next step is to configure the
device over SPI. In the software example, the HAL_afe031Init() function
configures the AFE031 and is defined within AFE03x_Config.c.
The steps below show the sequence the
function follows to correctly configure the device:
- Configure GPIOs.
- Setup SD and DAC pins on
the AFE device. Both these pins need to be brought low.
- Software example function:
HAL_afe031_cfgGpio();
- Configure SPI.
- Configure SPI module for
16-bit characters. For more information regarding SPI requirements, see
the AFE031 Powerline Communications Analog Front-End
Data Sheet.
- Software example function:
HAL_spi_cfg();
- Perform a soft reset on the AFE
device.
- Write 0x14 to the reset
register.
- Software example function:
HAL_afe031_softReset();
- Enable the Bias.
- Write 0x03 to the enable2
register.
- Software example function:
HAL_afe031_biasEnable();
- Select a Frequency Band.
- Write either 1 or 0 to the
CA_CBCD bit inside the Control1 Register. If a 1 is written, the
frequency response of the TX and RX filters will be configured to
CENELEC B,C,D. If a 0 is written, then CENELEC A will be
configured.
- Software example function:
HAL_afe031_bandSelect(1);
- Clear all interrupts
- Write 0x00 to the control2
register.
- Software example function:
HAL_afe031_clrAllInt();
- Configure all interrupts.
- Interrupts can be
configured by wrtiting to the control2 register. The software example
function currently only enables the T_flag that indicates thermal
overload.
- Software example function:
HAL_afe031_cfgInt();
- Enable zc.
- Write a 1 to the ZC bit in
the enable2 register.
- Software example function:
HAL_afe031_zcEnable();
- Write TX Gain - If Transmitting
- Write either a 0, 1, 2, or
3 to the TXG bits in the gain select register. The gains are as follows:
- 0 =0.25 V/V
- 1 = 0.5 V/V
- 2 = 0.707 V/V
- 3 = 1 V/V
- Software example function:
HAL_afe031_writeTxGain(UINT16 gain);
- Note that the
software example function uses an array to write the 0-3. Thus
when using the function, the input parameter corresponds to the
indice of the desired HAL_afe031_txGainLut array element.
For example passing 0 to the function corresponds to a gain of
0.25 V/V.
- Write RX Gain - If Receiving.
- Write 0-15 to the RXG bits
in the gain select register. The gains range from 0.25 V/V, when RXG is
set to 0x0, to 128 V/V, when RXG is set to 0xF.
- Refer to the Table 5-1 for specific gains.
- Software example function:
HAL_afe031_writeRxGain(UINT16 gain);
- Note that the
software example function uses an array to write the 0-15. Thus,
when using the function, the input parameter corresponds to the
indice of the desired HAL_afe031_rxGainLut array element.
The included array does not have values for all RX gain
configurations.
Once the above is complete, begin
the final few configurations needed based on the transmit or receive implementation
being used.