# Design of a Baseband Signal for the 406 MHz Satellite Emergency Radio Transmitter Based on STM32
## 3 Baseband Signal Generation METHOD
### Data Bits Design
#### 3.3.3 The Design of BCH-1 Coding  
Since the data bits to be checked are 61 bits, add the check bits, the total number of the bits is 82. In this paper, two 64-bit integers are designed to calculate the BCH check code, which means that 61 bits of data are XORed with the codeword polynomial in the previous time to get the check bit, and 21 zeros are added after the check bit obtained in the previous time to continue to XOR with the codeword polynomial.  
First, find the information polynomial.  
The BCH binary code is constructed as follows; the information polynomial is:  
\[m(x)=m_{k-1}x^{k-1}+m_{k-2}x^{k-2}+\cdots+m_{0} \tag{1}\]  
where \(m_{i}\in GF(2)\), the BCH code information polynomial, varies depending on the location of the COSPAS-SARSAT transmitter settings.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Bit** & **The Present** & **Value** \\ \hline
0 & Message format: & 0: short message; 1: long message \\
1 & Protocol: Location Protocol & 0 \\
2–11 & Country code & 412: China \\
12–15 & Type of location protocol & 0010: EPIRB \\
16–35 & MID & \\
36–39 & Specific Beacon & 0000 \\
40 & Latitude Sign & 0: North; 1: South \\
41–47 & Latitude Degree & \\
48, 49 & Latitude Minutes & \\
50 & Longitude Sign & 0: East; 1: West \\
51–58 & Longitude Sign & \\
59, 60 & Longitude Minutes & \\ \hline \hline \end{tabular}
\end{table}
Table 2: The bit of the first data protection field.  
In this paper, the data bits are 61 bits, i.e., the information polynomial is:  
\[\mathrm{m_{1}(x)}=\mathrm{m_{60}x^{60}+m_{59}x^{59}+\cdots+m_{0}} \tag{2}\]  
Second, find the codeword polynomial g(x), denoted as:  
\[\mathrm{g(x)}=\mathrm{g_{n-k}x^{n-k}+g_{n-k-1}x^{n-k-1}+\cdots+g_{1}x+g_{0}} \tag{3a}\]  
\[\mathrm{g(x)}=\mathrm{LCM}[\mathrm{m_{1}(x)},\mathrm{m_{3}(x)},\cdots,\mathrm{ m_{2n-1}(x)}] \tag{3b}\]  
Determine \(g_{1}(x)\) according to the look-up table:  
\[\mathrm{g_{1}(x)}=\mathrm{LCM}[\mathrm{m_{1}(x)},\mathrm{m_{3}(x)},\mathrm{m_ {5}(x)}]=\left(11554743\right)_{8} \tag{4}\]  
The codeword polynomial can be expressed as:  
\[\mathrm{g_{1}(x)}=x^{21}+x^{18}+x^{17}+x^{15}+x^{14}+x^{12}+x^{11}+x^{8}+x^{7}+ x^{6}+x^{5}+x^{1}+1 \tag{5}\]  
After the first modulo operation, we can get  
\[\mathrm{c_{1}(x)}=\mathrm{m_{1}(x)mod\,g(x)} \tag{6}\]  
As the number of check digits is less than 21, 21 bits of 0 are added to continue the XOR operation to obtain the check bits.  
After the second modulo operation, we can get  
\[\mathrm{r(x)}=\left(x^{21}\mathrm{c_{1}(x)}\right)\mathrm{mod\,g(x)} \tag{7}\]  
If the number of the check bits is less than 21, the result obtained by preceding 0s to the beginning of the code until the number of the check bits is 21.  
The specific implementation procedure in the STM32 microcontroller flows is as follows:  
1. Define variables and assign initial values to these variable according to the requirements of the baseband information.
2. Calculate the information polynomials and define them using 64-bit data to simplify XOR operation that follows.
3. Calculate the codeword polynomial.
4. Take the data with the same number of the information polynomial as the polynomial to perform XOR operation with the codeword polynomial. Then, take the obtained results as the higher bits of the new information, and act the part without XOR operation in the original data as  
The message bits are from bit 107 to bit 132, and the second data protection field is from bit 0 to bit 25. The data represented by each of the second data protection field are listed in Table 3.  
Variables are set up according to the data bits and are used to calculate the BCH code. The latitude and longitude information is obtained from the GPS receiver; the other data are set up according to the registration information of the transmitter; and the sequence is obtained as \(m_{2}\)(x).