PEmicro - P&E Microcomputer Systems: Over 30 years as an Industry leader in Embedded Systems Development Tools, debug probes, and production programmers
Cart New Account Login

HomeAbout usProductsSupportForumsBlogCustomer Service




P&E offers an easy and reliable way to control a Cyclone PRO via the built-in RS232 protocol. If you would like to follow along with our example, please pre-program your Cyclone PRO with a stand-alone image and configure your RS232 host device to operate at an 115200 baud rate, 8 data bits, no parity and 1 stop bit mode. You are now ready to enjoy the flexibility of controlling your Cyclone PRO by sending it a pre-defined set of byte strings. These commands cover full range of Cyclone PRO functionality, beginning with Executing All Commands of an Image (Same as Pressing the "Start" button) and ending with Dynamically Programming Data to Target.

In order to ensure that a given command reaches the Cyclone PRO without getting corrupted, each command is concluded by a CRC8 byte. Below is the command structure that should be followed every time the RS232 command is sent: [LENGTH] [COMMAND TYPE] [COMMAND ID] [PARAMETERS] [CRC8]. The user should calculate CRC8 and append it to all commands that are sent from a host system to a Cyclone PRO.

Let's go through a step-by-step example of CRC8 calculation for Execute All command:

The command consists of 4 bytes that include the CRC of $88: $03 $18 $11 $88.

Given an array of pre-calculated CRC values of:

const    crc8tab : array[0..255] of WORD = (
            $00,$07,$0E,$09,$1C,$1B,$12,$15,$38,$3F,$36,$31,$24,$23,$2A,$2D,
            $70,$77,$7E,$79,$6C,$6B,$62,$65,$48,$4F,$46,$41,$54,$53,$5A,$5D,
            $E0,$E7,$EE,$E9,$FC,$FB,$F2,$F5,$D8,$DF,$D6,$D1,$C4,$C3,$CA,$CD,
            $90,$97,$9E,$99,$8C,$8B,$82,$85,$A8,$AF,$A6,$A1,$B4,$B3,$BA,$BD,
            $C7,$C0,$C9,$CE,$DB,$DC,$D5,$D2,$FF,$F8,$F1,$F6,$E3,$E4,$ED,$EA,
            $B7,$B0,$B9,$BE,$AB,$AC,$A5,$A2,$8F,$88,$81,$86,$93,$94,$9D,$9A,
            $27,$20,$29,$2E,$3B,$3C,$35,$32,$1F,$18,$11,$16,$03,$04,$0D,$0A,
            $57,$50,$59,$5E,$4B,$4C,$45,$42,$6F,$68,$61,$66,$73,$74,$7D,$7A,
            $89,$8E,$87,$80,$95,$92,$9B,$9C,$B1,$B6,$BF,$B8,$AD,$AA,$A3,$A4,
            $F9,$FE,$F7,$F0,$E5,$E2,$EB,$EC,$C1,$C6,$CF,$C8,$DD,$DA,$D3,$D4,
            $69,$6E,$67,$60,$75,$72,$7B,$7C,$51,$56,$5F,$58,$4D,$4A,$43,$44,
            $19,$1E,$17,$10,$05,$02,$0B,$0C,$21,$26,$2F,$28,$3D,$3A,$33,$34,
            $4E,$49,$40,$47,$52,$55,$5C,$5B,$76,$71,$78,$7F,$6A,$6D,$64,$63,
            $3E,$39,$30,$37,$22,$25,$2C,$2B,$06,$01,$08,$0F,$1A,$1D,$14,$13,
            $AE,$A9,$A0,$A7,$B2,$B5,$BC,$BB,$96,$91,$98,$9F,$8A,$8D,$84,$83,
            $DE,$D9,$D0,$D7,$C2,$C5,$CC,$CB,$E6,$E1,$E8,$EF,$FA,$FD,$F4,$F3);

the following function should be executed with the initial CRC variable initialized to 0.

procedure ArrayCRC8(const a: array of byte; const len : byte; var crc: byte);
var
  i : byte;
begin
     for i := 0 to (len-1) do
         crc := crc8tab[crc xor a[i]];
end;

The first byte in the command representing its length should be omitted from CRC calculation.

Step 1: 0 xor $18 = $18. Retrieve CRC value from 24th location in our lookup table

                                 crc8tab[$18] = $48

Step 2: $48 xor $11 = $59. Retrieve CRC value from 89th location in our lookup table

                                    crc8tab[$59] = $88

Append the calculated CRC8 value of $88 to the end of your command to validate the correctness of the transmission.

 

 

 

 

 





search in blog posts

Tags

Product pages
Cyclone (21)
Cyclone FX (23)
Multilink (11)
Multilink FX (7)
GDB Server (9)
Prog ACMP (3)
Interface Library Routines (3)


Manufacturer
ARM (20)
NXP (31)
Atmel (2)
Cypress (1)
Maxim (1)
Nordic Semiconductor (1)
Silicon Labs (1)
Toshiba (1)
Renesas (5)


Categories
Production Programming (36)
Debug (14)
Automated Control (7)
Miscellaneous (32)



© 2017 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement