3 Demodulation Technique
The demodulation process is implemented using two instances of the TCB peripheral. The first instance operates in Input Capture Frequency Measurement mode and is used to distinguish between the two FSK frequencies. The received modulated signal is fed to the TCB input channel with the help of the EVSYS, and a capture interrupt is generated on each waveform period. Based on the captured value, the software determines if the measured frequency corresponds to a “mark” or a “space” and updates a state variable accordingly.
The second TCB instance, operating in the Periodic Interrupt mode, is used to sample the state variable. Initially, the interrupt is generated every 25, μs and the current value of the state variable is compared with the previous one. When a “mark” to “space” transition of the state variable is detected (equivalent to the Start bit), the demodulation process starts. The sampling rate is changed to match the one used during the modulation process but not before introducing an additional time offset to ensure correct data interpretation.
The periodic interrupt is now generated once every 1 ms and the data byte is reconstructed bit by bit, according to the state variable. Once the data byte is successfully reconstructed and the value of the state variable indicates a “mark” (equivalent to the Stop bit), the sampling rate is set back to 25 μs and the demodulated data byte is displayed in the serial terminal with the help of the USART peripheral.
