http://gambrose.esmartdesign.com/bcd%20library.zip
It includes an example that uses the BCD function to convert a byte to a string in 123 cycles instead of the 1069 cycles it takes the standard library not to shabby I thought (although I dose leave in leading zeros).
To use put BCD16.mcl in the uses/P16 folder of mikroC and P16F877A.mlk in the Defs folder.
Then open the Conversions example project. And have a fiddle.
There are three functions at the moment:
Code: Select all
char Swap(char toSwap);
unsigned long * Int2BCD(unsigned int num);
unsigned * Short2BCD(unsigned short num);
Any comments gratefully received
Note. This is a demonstration and is not for commercial use.