+ Reply to Thread
Results 1 to 7 of 7
  1. #1

    Default 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?

  2. #2
    Join Date
    Apr 2014
    Location
    Northeast
    Posts
    244

    Default 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.

  3. #3

    Default Re: Most memory saving way for comparing 98 preset values with ADC input?

    Is this ASM discussion forum?

  4. #4

    Default 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.
    George

  5. #5
    Join Date
    Aug 2005
    Location
    Michigan, USA
    Posts
    222

    Default 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?
    Last edited by Mike, K8LH; - 9th August 2018 at 00:13.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    1,496

    Default Re: Most memory saving way for comparing 98 preset values with ADC input?

    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
    This is more entertaining than Free to Air TV

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    1,496

    Default Re: Most memory saving way for comparing 98 preset values with ADC input?

    surprised no one pulled me up on this
    or inline asm

    @ FSR0L=22

    should be

    or inline asm

    or just

    FSR0L=22
    This is more entertaining than Free to Air TV

Similar Threads

  1. Manipulating ADC values....
    By dbachman in forum Code Examples
    Replies: 2
    Last Post: - 10th May 2016, 04:59
  2. ADC values above 4095 for 12 bit ADC
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st February 2015, 23:24
  3. ADC Max Impendance and Power saving
    By Michael Wakileh in forum Schematics
    Replies: 3
    Last Post: - 28th June 2009, 19:29
  4. Scaling ADC values
    By purkolator in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th November 2007, 06:14
  5. Inverting Input Values
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 21st August 2005, 08:09

Members who have read this thread : 14

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts