Speed C functions for C16x microcontrollers
Hans-Herbert Kirste, WAGO, Minden, Germany -- EDN, 8/3/2000
The Infineon C16x Series of µCs use an internal 16-bit-register architecture. The architecture can also process byte-wide functions. The µC uses byte moves to implement library functions such as memset() or memcopy(). This process makes the library code independent of count values and address values; both may be odd or even. The disadvantage is the loss of speed because of the need to process loop counters for every byte. Memory access also cuts the speed, because two cycles are necessary to write a word in 2 bytes. The code in Listing 1 implements a fast_memset() function that takes care of the byte count as well as the start access. Both may be odd or even. The function uses as many word moves as possible to preset the memory area. You can easily change the routine to process the copy function, memcopy(), with the same advantages. (DI #2569)
















