Most memory saving way for comparing 98 preset values with ADC input?
Hello.
Have to run a code in 12F1840, so quite limited in memory.
What I have. There are 98 preset values, pre-defined at programming stage, will not change, ranging from 0 to 100. The code should measure ADC input, convert it to 0-100 range value, and generate HPWM with duty cycle according to one defined in table. Say ADC reading is 20, then data is read from 20th cell of table, and data is 45 in that table. And so on. PBP allows several ways to do this, like multiple if-then, arrays, etc. Which one will be most memory efficient?
Re: Most memory saving way for comparing 98 preset values with ADC input?
On page 13 of the PIC12F1840 Data sheet, Section 3.1.1.1, the RETLW ASM command is explained. It's used on the following page as well. Finally, on page 299 the Instruction RETLW is covered.
Re: Most memory saving way for comparing 98 preset values with ADC input?
Is this ASM discussion forum?
Re: Most memory saving way for comparing 98 preset values with ADC input?
Try coding it as a huge SELECT statement, you might be surprised how little memory it uses.
Re: Most memory saving way for comparing 98 preset values with ADC input?
Gentlemen... Does PBP provide a way to access Special Function Registers, like FSR0L, FSR0H, INDF0, etc., directly?
Re: Most memory saving way for comparing 98 preset values with ADC input?
Quote:
Does PBP provide a way to access Special Function Registers, like FSR0L, FSR0H, INDF0, etc., directly?
yes there are a number of ways
my favourite is
timer0 var byte ext
@timer0 = TMR0
OR even
myFSR var word ext
@myFSR= FSR0L
or inline asm
@ FSR0L=22
OR USING PBP MACRO
PBPBYTE VAR BYTE
PBPWORD VAR WORD
@ MOVE?BB _PBPBYTE,FSR0L
@ MOVE?WW _PBPWORD,FSROL
Re: Most memory saving way for comparing 98 preset values with ADC input?
surprised no one pulled me up on this
Quote:
or inline asm
@ FSR0L=22
should be
or inline asm
or just
FSR0L=22