III - Advanced Project.

1. Adapting project to elementary task.

See Tutorial page for project bases.
In this part, you will have to modify particular files of the previous folder Test/.

1.1 Integration of C Source files into task(s).

  • task_name.c stating void task_name (void) { ... }.
    Here you can either call the C main function in the task_name function or adapting your main file into one or several tasks (for simultaneity during process).
  • task_name.h stating extern void task_name (void); and other intern functions.

1.2 Definition of your task(s) to be called.

  • tasks.h defining OSTCBP of all predifined tasks i.e. the way of specifying a pointer to a particular Salvo Task Control Block. More information is available on Salvo User Manual.
  • task_cmd.c which is a tool provided by Test/ that allows to resume/stop your task(s).
  • main.c i.e. the basic implementation to call your task(s). All statements are essential for Salvo and CSK to work.

2. Integration of a Reed-Solomon encoder/decoder.

A highly convenient implementation of a Reed-Solomon code is available on RS Code Website and will be integrated in the following.

2.1 Presentation of Reed-Solomon (n=255,k=239,t=8).

This is an implementation of a Reed-Solomon code with 8 bit bytes, and a configurable number of parity bytes. The maximum sequence length (codeword) that can be generated is 255 bytes, including parity bytes. It provides the following C/H - files :
(1) rs.c, (2) berlekamp.c, (3) crcgen.c, (4) ecc.h and (5) example.c

The rs.c file contains an algorithm to generate the encoder polynomial for any number of bytes of parity, configurable as the NPAR constant in the file ecc.h. For this RS code, G(x) = (x-a^1)(x-a^2)(x-a^3)(x-a^4)...(x-a^NPAR) where 'a' is a primitive element of the Galois Field GF.
rs.c contains also a decoder that generates four syndrome bytes, which will be all zero if the message has no errors.
The more general error-location algorithm is the Berlekamp-Massey algorithm (implemented in berlekamp.c), which will locate up to four errors, by iteratively solving for the error-locator polynomial.

More information is available on rs.doc and config.doc.

2.2 Task Example.

The example of Reed-Solomon code example.c can be used to implement our encoder/decoder in a simple task. See 1.1 and 1.2 for the definition and integration of task_example.c

  • The following message (or information word) is considered at the encoder :

    Message of 86 characters (or bytes)
  • Then, errors due to a fictional channel are added to the codeword :

    Code of adding errors

3. Displaying results.

3.1 In simulation.

First of all, we want to simulate the behavior of the dsPIC33 and get an output message window in order to watch our results :
1. Right-click on your project > Properties > Chose Simulator as Hardware Tool > Apply
2. Right-click on your project > Properties > Simulator > Chose Uart IO Options > Check Enable Uart1 IO > Apply


Checking Output UART Window

After building and debugging the program (through Debug Main Project), results are printed in the UART 1 Output window :


Displayed result

It is now possible to see the codeword, the errors and the correction.

3.2 On board.

Henceforth, we can switch from the Simulator to ICD3 and connect the development board. It has been necessary to plug in some LEDs on the board to see the evolution of the program without interface and compare it to the previous results.

In this part, we are focusing the last byte of the message :

- Char Code ASCII Hexadecimal Binary
Codeword 2 50 0x32 0b00110010
Error pattern - - 0x01 0b00000001
Erroneous Codeword 3 51 0x33 0b00110011

Indeed, we denote the modification of the last character from 2 to 3 i.e. from 0b00110010 to 0b00110011 that can be illustrated by LEDs : 1 -> light, 0 -> no light.

A first function void display_6bits(unsigned char* string, int index) has been written in order to light up the six LEDs according to the six most right bits of the binary representation of the character indicated by the index in string (See the end of I - Equipment). A second function void reset_leds(void) switchs off the LEDs.


__________ a. Codeword : 0bXX110010 ________________ b. Erroneous codeword : 0bXX110011 ____________ c. Corrected codeword : 0bXX110010 ______


4. Complete project.

This project is available on Files widget.
Note that it has been built by including and putting together all necessary Inc/ Src/ and Lib/ needed and described in the Tutorial. Moreover the adapted files of the Reed-Solomon encoding/decoding are available in Reed_Solomon_Code/


Tree of folders

Please take care by adding these folders to your project to have the following configurations :


Structure of project


Including common directories. NB:Take care of the order!

For more information, visit the Tutorial.