MCC Configuration

The MCC configuration was made for PIC16F1779 and Curiosity HPC development board, but the transceiver solution can be implemented on any 8-bit MCU that has a CLC, an EUSART, a TMR with HLT and two TMRs with gate control. The configuration is based on a system clock of 4 MHz. All the required peripherals are available for configuration in MCC.

The tools versions used are:

These are the configuration steps:

  1. 1.Start MPLAB X and create a new project for PIC16F1779.
  2. 2.Open MCC.
  3. 3.In System Module, change internal clock to 4MHz_HF and disable PLL by unchecking PLL Enabled checkbox.
    Figure 1. System Module
  4. 4.From Device Resources → Peripherals shown in Figure 2, select a CLC, an EUSART and three Timer modules.
    Figure 2. Peripherals Selection
  5. 5.The CLC must act like an XOR gate, with its input signals coming from EUSART, as shown in Figure 3; the demo is using CLC4:
    • Enable CLC → uncheck box
    • Mode → OR-XOR
    • Configure the first signal to be the Clock (CK) channel from the EUSART module, and enable the connection to the first or the second gate
    • Configure another signal to be the Data (DT) channel from the EUSART module, and enable the connection to the third or the fourth gate
    • Negate the Data signal by pressing on the top of the gate to which it was assigned
    Figure 3. CLC4 Configurations
  6. 6.The EUSART must be configured as synchronous and with a baud rate of 1200, as indicated in Figure 4, to satisfy the DALI-2 requirements, and also the EUSART interrupts must be enabled:
    • Mode → Synchronous
    • Sync Mode → master
    • Baud Rate → 1200
    • Enable EUSART Interrupts → Check
    Figure 4. EUSART Configuration
  7. 7.A Timer was used to generate an interrupt after the end of the transmission, leaving the communication channel into an Idle state. The demo is using TMR8 and the configuration is illustrated in Figure 5:
    • Enable Timer → uncheck box
    • Clock Source → FOSC/4
    • Postscaler → 1:1
    • Prescaler → 1:32
    • Timer Period → 416 μs
    • Enable Timer Interrupt → check box
    • Callback Function Rate → 416 μs
    Figure 5. TMR8 Configuration
    Note: TMR8 is also used by the decoder, which will modify the prescaler and Period values. There is no problem, since the decoder and the encoder will never be both active at the same time. When disabled, the decoder will revert the Period to the value set in MCC. The encoder will set the prescaler back to 1:32 when needed.
  8. 8.Additionally, the decoder uses two timers with gate control for measuring the actual baud rate of the received signal and adjust the EUSART baud rate accordingly. The demo is using TMR1 and TMR5 for this, and the configurations are illustrated in Figure 6, respectively Figure 7:
    • Enable Synchronization → uncheck box
    • Enable Gate → check box
    • Enable Gate Toggle → check box (just for TMR1)
    • Enable Gate Single-Pulse mode → check box
    • Gate Polarity → high
    Figure 6. TMR1 Configuration
    Figure 7. TMR5 Configuration
  9. 9.In Pin Manager from Figure 8, the user must select the CLC module output pin, buttons input pins, EUSART DT pin, LEDs output pins, TMR1 and TMR5 gate pins and TMR8 input pin:
    • CLC4OUT → output on Port RD0; disable Analog
    • EUSART DT → connect to Port RB5
    • Pin Module → input Port RB4; rename the pin to S1; enable Weak Pull-Up
    • Pin Module → input Port RC5; rename the pin to S2; enable Weak Pull-Up
    • Pin Module → output Port RA4; rename the pin to LED_D2; disable Analog
    • Pin Module → output Port RA5; rename the pin to LED_D3; disable Analog
    • Pin Module → output Port RA6; rename the pin to LED_D4
    • Pin Module → output Port RA7; rename the pin to LED_D5
    • TMR1 T1G → input from Port RB5
    • TMR5 T5G → input from Port RB5
    • TMR8 T8IN → input from Port RB5
    Figure 8. Pin Manager Configurations
  10. 10.The configurations for Manchester transceiver were made, so the Generate button can be pressed.