1.4.1.1 Initialization
In the code of the PLC & Go example application, the PLC PHY driver initialization is
performed during the first states of the state machine implemented in the function
APP_PLC_Tasks
:APP_PLC_STATE_IDLE
initializes the variables related to transmission parameters and coupling stage.APP_PLC_STATE_INIT
opens the PLC PHY driver to load the PLC PHY binary. If this state is reached because of a frequency band change (APP_PLC_STATE_SET_BAND
), the PLC PHY driver needs to be initialized first.APP_PLC_STATE_OPEN
waits for the PLC PHY driver to be ready (PLC PHY binary loaded completely and validated). Once the PLC PHY driver is ready:- The PLC PHY driver and
PVDD monitor service callbacks are set in order to receive different
events:
- Data indication
event is managed by the
APP_PLC_DataIndCb
function to process all the PLC messages received. - Data confirm
event is managed by the
APP_PLC_DataCfmCb
function to process the results of PLC transmissions. - Exception events
are managed by the
APP_PLC_ExceptionCb
function. - PLC sleep mode
disable event is managed by the
APP_PLC_SleepModeDisableCb
function to restart the configuration once sleep mode is disabled. - PVDD monitor
events are managed by the
APP_PLC_PVDDMonitorCb
function to enable/disable the PLC transmission.
- Data indication
event is managed by the
- The initial PLC PHY
parameters (PIBs) are configured, including:
- Transmission
coupling parameters. This is always required. It can be done
using the function
SRV_PCOUP_Set_Config
. - Transmission and
reception CRC computation
(
PLC_ID_CRC_TX_RX_CAPABILITY
) is enabled in the PHY layer. The CRC format is the same that uses the G3-PLC protocol. This is not needed (by default it is disabled in the PHY layer) if other CRC format is required or if the CRC is computed by the upper layer. - Static notching
(
PLC_ID_TONE_MASK
) only ifAPP_PLC_STATIC_NOTCHING_ENABLE
is not 0 and band is CENELEC-A (the example only implements it for CENELEC-A, but the PHY layer support it also for the other frequency bands). Each carrier corresponding to the frequency band can be notched (no energy is sent in those carriers). Each carrier is represented by one byte (0: carrier used; 1-255: carrier notched). By default it is all 0's in the PHY layer (static notching disabled). The same Tone Mask must be set in both transmitter and receiver, otherwise they don't understand each other. - The PLC PHY version is read.
- Transmission
coupling parameters. This is always required. It can be done
using the function
- The PVDD monitor service is started, needed to enable/disable the transmission of the PL460 device using the TXEN pin. The PVDD voltage is monitored and PLC transmission is disabled in case the voltage is not in the expected range, to avoid PL460 damage. If the PVDD voltage is in the expected range, PLC transmission is enabled.
case APP_PLC_STATE_OPEN: { /* Check PLC transceiver */ if (DRV_PLC_PHY_Status(DRV_PLC_PHY_INDEX_0) == SYS_STATUS_READY) { /* Configure PLC callbacks */ DRV_PLC_PHY_ExceptionCallbackRegister(appPlc.drvPlcHandle, APP_PLC_ExceptionCb, 0); DRV_PLC_PHY_TxCfmCallbackRegister(appPlc.drvPlcHandle, APP_PLC_DataCfmCb, 0); DRV_PLC_PHY_DataIndCallbackRegister(appPlc.drvPlcHandle, APP_PLC_DataIndCb, 0); DRV_PLC_PHY_SleepDisableCallbackRegister(appPlc.drvPlcHandle, APP_PLC_SleepModeDisableCb, 0); /* Apply PLC initial configuration */ APP_PLC_SetInitialConfiguration(); /* Disable TX Enable at the beginning */ DRV_PLC_PHY_EnableTX(appPlc.drvPlcHandle, false); appPlc.pvddMonTxEnable = false; /* Enable PLC PVDD Monitor Service */ SRV_PVDDMON_CallbackRegister(APP_PLC_PVDDMonitorCb, 0); SRV_PVDDMON_Start(SRV_PVDDMON_CMP_MODE_IN); /* Init Timer to handle blinking led */ appPlc.tmr1Handle = SYS_TIME_CallbackRegisterMS(APP_PLC_Timer1_Callback, 0, LED_BLINK_RATE_MS, SYS_TIME_PERIODIC); /* Set PLC state */ appPlc.state = APP_PLC_STATE_WAITING; } } break;
- The PLC PHY driver and
PVDD monitor service callbacks are set in order to receive different
events: