Order Tray | Contact Us | Home | SIG Lists

[ax25-layer2] NRZI problem?

Paula g8pzt at blueyonder.co.uk
Fri May 4 19:47:59 UTC 2012


Your code doesn't seem to account for bit stuffing... A zero following a 
sequence of 5 consecutive ones is a "stuffed" bit, and must be discarded.


----- Original Message ----- 
From: "Mario Doerr" <mailinglist at xyphur.de>
To: <ax25-layer2 at tapr.org>
Sent: Friday, May 04, 2012 6:49 PM
Subject: [ax25-layer2] NRZI problem?


> Hi all,
>
> i'm developing a PIC based application where i want to en-/decode packets 
> with a dedicated modem chip. Currently i'm working on the receiving part. 
> The modem chip is connected via SPI, receiving 8 bits and send the byte to 
> the PIC controller. This works fine. If i send the data back, the packet 
> can be decoded on my PC with a software like TrueTTY or MixW.
>
> Now i have implemented the decoding algorithm on the PIC. First i redo the 
> NRZI stuff, then sync to the 0x7e packets and try to decode the calls from 
> AX.25 frame, but i think the NRZI decoding fails. (I'm using the AX.25 
> decoding stuff successfully in the software to get a human readable text 
> from KISS frames).
>
> Here is my packet generated from MixW:
>
> NOCALL-0 -> QST-0  UI^ Pid=F0
> ..CQ CQ CQ de DC1MD DC1MD DC1MD..CQ CQ CQ de DC1MD DC1MD DC1MD..pse K..?
>
>
> Here are the first bytes from the modem chip:
>
> E7 E7 E7 E4 56 50 51 21 20 20 73 97
>
> And here is what i get after my NRZI decode algorithm:
>
> 0x7e '~'
> 0x7e '~'
> 0x7e '~'
> 0x7c '|'
> 0xa0 ' '
> 0xa4 '¤'
> 0xa8 '¨'
> 0x40 '@'
> 0x40 '@'
> 0x40 '@'
> 0xe2 'â'
> 0x9e 'ž'
> 0x9e 'ž'
>
> The first three start bytes are ok, then i get a 0x7c, which is wrong and 
> i get a valid call (QST   ) with 3 spaces.
>
> I've repeated to decode (and receive) this and other pakets but the result 
> is always the same. Sometimes one bit is wrong, or a whole byte is 
> inverted after the NRZI decoding.
>
> Because this is really driving me crazy, i've captured some data and try 
> to decode it on the PC (which is more comfortable). My NRZI decode 
> function is very simple:
>
> unsigned char NRZI_rd_byte(unsigned char input)
> {
> unsigned char byte = 0;
> unsigned int n;
> static unsigned char toggle = 0;
>
> for(n=8; n != 0; n--)
> {
> byte <<= 1;
>
> if( ( input & 0x80 ) == ( toggle & 0x80 ) )
> byte |= 0x01;
>
> toggle = input & 0x80;
>
> input <<= 1;
> }
> return(byte);
> }
>
> Maybe someone has an idea what's the problem, any ideas are welcome.
>
> I'm not really sure if it is possible to do packet with my modem chip, 
> because it is working with bytes.
>
> An other question is, if there is somewhere testdata for any step of the 
> decoding process (raw, NRZI, synced, bit stuffed,...).
>
> 73 de DC1MD
>
> _______________________________________________
> ax25-layer2 mailing list
> ax25-layer2 at tapr.org
> https://www.tapr.org/cgi-bin/mailman/listinfo/ax25-layer2
> 




More information about the ax25-layer2 mailing list