5.1 DALI-2 Transmitter Demo Implementation
The functionality of the code is briefly described in Figure 5-1. After the hardware configurations mentioned in the previous chapter through the MCC selection steps, the demo application counts every push of the button, stores the value in a byte and will further send DALI-2 frames. In case of the frames with more than one byte of data, the first one will contain the counted value and the others will be filled with zeros.
- For a DALI frame implementation, the user
must add the
manchester_encoder.c
andmanchester_encoder.h
files to the project. These files implement the DALI-2 frame transmissions providing ‘DALI_Send_Frame(block_of_bytes, number_of_bytes)
’ function, which takes as a first argument a block of bytes representing the data of the frame, and as a second argument, the number of bytes. In conclusion, both forward and backward frames can be sent by calling the same function but with a different number for the second argument (1 for backward and 2 for forward).Note: The function will activate the 9-bit transmission option of the EUSART for the first byte of the frame, will deactivate it once it is done, and will change the endianness of every byte to MSB-LSB to comply with DALI-2 requirements. More details can be found in the following figure. - In ‘
main()
’, after the initializing procedures, the user must enable the global and peripheral interrupts required by TMR8. - In ‘
while (1)
’, the state of the buttons is checked and, if a button is clicked, the respective counter is incremented and a DALI-2 frame is sent.