aloomis
aloomis

Reputation: 1

Making a PN9 Scrambler for CC1110 in GNU Radio

I am trying to implement the data whitening used by the CC1110 radio IC in GNU radio companion, as described in this app note.

It looks like it uses a LFSR with PN9 sequence (with x^9 + x^5 + 1 polynomial) and a seed value of 0x1FF. I think the "Scrambler" block in GNU radio could handle this just fine, but I'm unsure that I'm using the correct parameters (I'm modeling these parameters off of this post).

Mask: 0x11
Seed Value: 0x1FF
Length: 8

Here is my flowgraph: flowgraph

I have an input binary file with the following contents:

$ xxd bytes.bin 
00000000: 0a00 0102                                ....

This is the example data in the app note linked above. The output file contents are:

$ xxd bytes_out.bin 
00000000: 0101 0101                                ....

The example in the app note (page 5) has a different result:

Data: / 0000 1010 / 0000 0000 / 0000 0001 / 0000 0010 / …
PN9: / 1111 1111 / 1110 0001 / 0001 1101 / 1001 1010/ …
Result: / 1111 0101 / 1110 0001 / 0001 1100 / 1001 1000 /…

I am new to GNU radio and DSP so any help on this would be much appreciated. I think I might just be using the wrong Scrambler block parameters, but there might be a fundamental misconception I have with GNU radio. Thanks!

Upvotes: 0

Views: 507

Answers (1)

ferdymercury
ferdymercury

Reputation: 826

Here is a C++ code snippet to generate that PN9 sequence, that you can run easily with an online compiler:

#include <iostream>
#include <bitset>

using namespace std;

int main() {
    bitset<9> lfsr;
    lfsr.flip();//Seed: all 1s
    const unsigned int period = (1 << 9) - 1;
    for(unsigned int i = 0; i < period; ++i)
    {
        if(i%8 == 0)
        {
            cout << lfsr[7] << lfsr[6] << lfsr[5] << lfsr[4] << " " << lfsr[3] << lfsr[2] << lfsr[1] << lfsr[0] << " / ";
        }
        
        const bool newBit = lfsr[0] ^ lfsr[5];
        lfsr >>= 1;
        lfsr[8] = newBit;
    }
    cout << endl;
}

Output is:

1111 1111 / 1110 0001 / 0001 1101 / 1001 1010 / 1110 1101 / 1000 0101 / 0011 0011 / 0010 0100 / 1110 1010 / 0111 1010 / 1101 0010 / 0011 1001 / 0111 0000 / 1001 0111 / 0101 0111 / 0000 1010 / 0101 0100 / 0111 1101 / 0010 1101 / 1101 1000 / 0110 1101 / 0000 1101 / 1011 1010 / 1000 1111 / 0110 0111 / 0101 1001 / 1100 0111 / 1010 0010 / 1011 1111 / 0011 0100 / 1100 1010 / 0001 1000 / 0011 0000 / 0101 0011 / 1001 0011 / 1101 1111 / 1001 0010 / 1110 1100 / 1010 0111 / 0001 0101 / 1000 1010 / 1101 1100 / 1111 0100 / 1000 0110 / 0101 0101 / 0100 1110 / 0001 1000 / 0010 0001 / 0100 0000 / 1100 0100 / 1100 0100 / 1101 0101 / 1100 0110 / 1001 0001 / 1000 1010 / 1100 1101 / 1110 0111 / 1101 0001 / 0100 1110 / 0000 1001 / 0011 0010 / 0001 0111 / 1101 1111 / 1000 0011 / 

Upvotes: 0

Related Questions