The code checks if bit 2 of the high byte of the wordsized variable "counter" is set. If it is, the program has looped around 1024 times, if not it keeps looping.
There is really no math involved, 1024dec = 0400hex = 0000010000000000bin.
You don't want to check for anything more complicated than if a single bit is being set or cleared. That would slow the ADconversion down, not something you want to do. I'm not saying it can't be done, just that it wouldn't be very easy. Especially if you don't know assembler and i get the impression that you don't.
My advice is that you stick with 10 bits(1024) and when the conversion is complete you scale the result to your desired value. That can be done in various ways. Here's a few..... all will scale to 752.
Dummy = ADresult * 752
ScaledResult DIV32 1024
ScaledResult = ADresult */ 188 '752/1024*256=188
ScaledResult = ADresult ** 48128 '752/1024*65536=48128
/Ingvar




Bookmarks