30.3.10.6 Performance

To process each byte of data (8-bits), the calculation takes one peripheral clock. However, it reads a multi-byte Flash word and operates on all those bytes each read. Since the Flash Read Word, or Flash Word in Bytes (FWB), is 32 bytes long it takes 32 clocks to calculate a CRC.

Since the CRC is reading the Flash it must also use the system Flash Wait States, FWS. The time to get the Flash data into the shift register is FWS+1. Also, if the system continues to access flash, the CRC logic is lowest priority and must wait until there is an idle cycle.

The logic periodically reads the flash to supply data to the calculation. The PERIOD is programmable from 0 to 4095 extra Period Clock (PerCLK) counts from the end of the calculation. (The PerCLK is an 8MHz fixed frequency clock derived from the 48 MHz Precision Internal RC Oscillator.) Though selecting a period of zero clocks will not completely cut off the system flash bandwidth, it could be severely limiting. System bandwidth can be less than half under such conditions. Low period selections are useful during light loads or scheduled checks. When running with auto repeat, an appropriate period value is one that finishes the calculation before to the maximum user allotted time.

Lastly, the CRC needs to know the Message Length, MLEN, in bytes over which to perform the calculation. Note that neither the starting address of the message nor the message length need to be aligned to Flash Read Bytes.

CRC Performance Equation

First, let:

TMCALC = CRC message calculation time

TSTEP = CRC step time (time to calculate each step in the CRC)

TACC = Flash Access Time

TPER = Period between CRC accesses

PAPB = Peripheral Bus Period = 1/Peripheral Bus speed

PAHB = AHB Period = 1/AHB Clock speed

PPerCLK = Period of Period Clock = 1/8 MHz = 125 ns

FWB = Flash Word in Bytes = 32

Then:

TMCALC = (TSTEP + 2*TACC + TPER)*MLEN/FWB

Where:

TSTEP = FWB*PAPB

TACC = (FWS+1)*Pahb

TPER = PPerCLK * PERIOD + 2 * PAHB, if PERIOD > 0

= 0, if PERIOD = 0.

The equation for TMCALC includes the term 2*TACC instead of just TACC because the CPU is likely reading, forcing the CRC engine to wait before reading. The factor MLEN/FWB represents the number of accesses needed to read the message.

If TMCALC is known, we can solve for PERIOD:

PERIOD = 8e6 * { (FWB/MLEN)*TMCALC – [ (FWB*PAPB + (2*FWS + 2)PAHB + 2*PAHB ] }

CRC Performance Example

Assume the application must calculate the CRC on an 80 Kbyte message every 800 ms. Further, assume that both the AHB and APB are running at 100 MHz and that Flash needs four wait states. Then:

TMCALC = 800 ms = 800,000,000 ns

MLEN = 80 Kbytes = 80*1024 = 81920 Bytes, so MLEN/FWB = 2560

PAPB = 1/100 MHz = 10 ns

PAHB = 1/100 MHz = 10 ns

FWS = 4

Solving for the value of PERIOD,

PERIOD = 8e6 Hz* { (800,000,000 ns)/2560 – [ 32*10ns + (8 + 2)*10 ns + 2*10 ns ] }

= 8e6 Hz * { 312,060 ns } = 2496.48

= 2496 (rounding down)