Author Topic: Calculate Ecc byte for MIPI DSI header  (Read 5550 times)

0 Members and 1 Guest are viewing this topic.

Offline joy586210Topic starter

  • Newbie
  • Posts: 9
  • Country: tw
Calculate Ecc byte for MIPI DSI header
« on: March 13, 2016, 11:58:23 am »
Just find a piece of C code to calculate Ecc byte for MIPI DSI header.
The Ecc byte is derived from Hamming-modified Code (72,64). DSI systems shall use a 5+1 bit Hamming-modified
code (30, 24), allowing for protection of up to twenty-four data bits.

The Hsync start packet is 0x21,0x00,0x00,0x12.

I just compile it as vs2008 project, and verify the Hsync start short packet ecc byte is 0x12.
While it is 0x0f in lattice RD1184 implementation, so there must be something wrong.

Command output:
D:\mipi\mipi_header_ecc\mipi_header_ecc\Debug>mipi_header_ecc.exe
Checking Codes(eg.0x1234AF, "-" for exit): 0x210000
Result:0x12


Reference:
1, Version 1.02.00 28-Jun-2010  MIPI Alliance Specification for DSI
2, http://www.metsky.com/archives/618.html

 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13834
  • Country: gb
    • Mike's Electric Stuff
Re: Calculate Ecc byte for MIPI DSI header
« Reply #1 on: March 13, 2016, 12:21:08 pm »
This is the code I used
Code: [Select]
char parity (unsigned long val)
{ // calc XOR parity bit of all '1's in 24 bit value
unsigned long i,p;
p=0;for(i=0;i!=24;i++) {p^=val;val>>=1;}
return(p&1);
}

unsigned long add_ecc(unsigned long cmd)
{// add ecc byte to b29-24 of 24 bit command packet (lsbyte first)
cmd&=0x00ffffff; 
if(parity(cmd & 0b111100010010110010110111)) cmd|=0x01000000;           
if(parity(cmd & 0b111100100101010101011011)) cmd|=0x02000000;
if(parity(cmd & 0b011101001001101001101101)) cmd|=0x04000000;
if(parity(cmd & 0b101110001110001110001110)) cmd|=0x08000000;
if(parity(cmd & 0b110111110000001111110000)) cmd|=0x10000000;
if(parity(cmd & 0b111011111111110000000000)) cmd|=0x20000000;
return(cmd);
}
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline joy586210Topic starter

  • Newbie
  • Posts: 9
  • Country: tw
Re: Calculate Ecc byte for MIPI DSI header
« Reply #2 on: March 14, 2016, 02:04:44 am »
Thanks, it's more efficient!   :D
And result is also 0x12.

D:\Users\Projects\eevblog_mipi_ecc\Debug>eevblog_mipi_ecc.exe
Input command packet(eg.0x123456, lsb first): 0x000021
Result:0x12000021
« Last Edit: March 14, 2016, 08:09:35 am by joy586210 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf