MPXA4115A picbasic code


Closed Thread
Results 1 to 40 of 104

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    963


    Did you find this post helpful? Yes | No

    Default Why "DEFINE" ?

    Thanks bitmaniac,

    I have read Alain's explanation about "oversampling" and "rolling mean value" in a previous post but I'm still not clear why it is necessary to declare a DEFINE to do so.

    I think, I don't understand what the DEFINE does.

    Any clue for me?
    Roger

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post
    Thanks bitmaniac,

    I have read Alain's explanation about "oversampling" and "rolling mean value" in a previous post but I'm still not clear why it is necessary to declare a DEFINE to do so.

    I think, I don't understand what the DEFINE does.

    Any clue for me?
    Hello,
    You are correct you should set the pic to 10 bits:
    DEFINE ADC_BITS 10

    http://www.darreltaylor.com/DT_Analog/

    If you study Darrel's example in the above link, bottom of the article.
    You set your oversampling resolution in this line:


    ADbits = 12 ; set to 12-bit resolution

    Regards
    Mark
    Last edited by mark_s; - 3rd June 2010 at 16:45. Reason: add link

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by flotulopex View Post

    I think, I don't understand what the DEFINE does.

    Any clue for me?
    Hello, Roger

    DEFINE only set a constant ... used to DEFINE some processor module or macros configs.

    the value is tested, and relevant settings are chosen by the compiler ( sort of conditionnal assembly - if you prefer ... sort of !!! )

    just look at the difference ( in the asm listing) between DEFINE ADC_BITS 8 and ADC_BITS 10 ...

    Should be little differences in the ADCONx setting values ... don't you think ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    963


    Did you find this post helpful? Yes | No

    Default ok

    Thanks Alain,

    I was confused because of the value (16) in Darrel's code example.

    I now understand what this particular DEFINE does
    Roger

Similar Threads

  1. sample code for AT45DB642D in Picbasic Pro
    By itsssyam in forum General
    Replies: 0
    Last Post: - 10th March 2010, 07:01
  2. 16f887 44 pin demo board code problem?
    By jessey in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 7th December 2008, 15:17
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 19:31
  4. PicBasic code problems with a 16F84A
    By Lauren Barta in forum mel PIC BASIC
    Replies: 3
    Last Post: - 30th May 2006, 23:50
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 11:04

Members who have read this thread : 0

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