In this post the final version of the transmitter will be introduced
The transmission of the data is performed inside the Timer1 interrupt routine. Timer1 is initialized to run at 100 us by the following code
// TimerA1 UpMode Configuration Parameter Timer_A_initUpModeParam initUpParam_A1_PWM = { TIMER_A_CLOCKSOURCE_SMCLK, // SMCLK Clock Source TIMER_A_CLOCKSOURCE_DIVIDER_1, // SMCLK/1 = 2MHz 200, // 100us period TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE , // Enable CCR0 interrupt TIMER_A_DO_CLEAR, // Clear value true // Start Timer };
The timer ISR routine will handle the transmission of the data. The logic flowchart is shown in diagram below
The display will show the following information
- 1. The Hamming code being transmitted
- 2. The raw value being transmitted
- 3. The status of the transmission
- 4. An heart-beat to signals that the main loop is running
- 5. An activity indicator that signals that the Timer1 ISR and the transmission routine is running
The visualization of the encoded value and the raw value can be selected by pressing the S2 button. The value to send can be increased by means of the S1 button
The source code is attached to the post.