The basics


Closed Thread
Results 1 to 15 of 15

Thread: The basics

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    And that's what's called "RTFM"
    LOL - well I'm try. I know that to get help here it helps if one can be seen to be doing the basics, such as RTFM... even though I may not fully comprehend it

    Quote Originally Posted by skimask View Post
    As you said - "bit 3 needs to have a value of 1110"
    A bit is a "Binary digIT". It can't have a value of 1110. Just like you can't count over 5 on one hand....If you take another good look at that datasheet, you'll see that the ADCON register (and I think you really want the ADCON1 register) has 8 bits, like most other registers.
    So its the lower half of a byte - having 8 bits

    Quote Originally Posted by skimask View Post
    Therefore...it follows, according to the PBP manual and it's explanation of the usage of the "%" character, you can set bits in any register or variable from most significant bit to least significant bit, left to right.
    Hence
    ADCON1 = %00001110
    So it follows that we can set values for ADCON, CMCON etc much the same way as we can set which pins are inputs and outputs on each port eg PORTB=%00000000

    Quote Originally Posted by skimask View Post
    If that answers your question, great.
    If it's entirely too much 'duh' information, sorry, didn't mean to insult your intelligence.
    yes it does help and I appreciate the effort to post in such detail

    Quote Originally Posted by skimask View Post
    Is that the ticket?

    (EDIT: Re-reading your post above, I see that is in fact what you really wanted to do...Hopefully this clears it up for you)
    Yup - that helps a lot. Like I said its been a while since I programmed these things and as I get older I seem not to be able to retain things as easily as I used to
    Thanks

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    So its the lower half of a byte - having 8 bits
    ......
    So it follows that we can set values for ADCON, CMCON etc much the same way as we can set which pins are inputs and outputs on each port eg PORTB=%00000000
    ......
    yes it does help and I appreciate the effort to post in such detail
    1) Yes - lower half, the lower 'nybble', bottom 4 bits...

    2) Yes, that's exactly the case! Almost everything in the PIC10/12/14/16/17/18 world (in general, the small microcontroller world) is based on the BYTE...8 bits...2 nybbles...left to right = most significant to least significant (gotta be careful when you start playing with WORDs, QUADs, LONGs, etc. Some MCU's don't order them the same in memory, little endian vs. big endian).

    Detail - I got on a roll, a rambling roll. Hopefully that little lecture will catch on and other 'less experienced' folks will read and comprehend it.
    Last edited by skimask; - 21st June 2008 at 23:30.

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Ok I now have something workable, but its still not behaving as I would hope.

    I'm using the EasyPIC5 board, with 10K pot set to RA1. The following "abridged" code seems to give a decaying value for the varible D used to store the ADCIN.

    Code:
    main:
    ADCIN 0, D                                      
    LCDOUT $FE,$C0, "Chase Speed " ,#D	
    
    'DO MAIN PART OF FLASH LEDS IN SEQUENCE HERE'
    
    PAUSE D                                         
    NEXT                                           
    goto main:
    With the post set to +5 it gives a reading (decimal) for D of 40ish, which then drops to 12 and then flucuates between 12 and 16, meaning that the speed at which the LEDS flash can't stay constant.

    Any Ideas ?

    (I can post full code if require)

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    with 10K pot set to RA1.
    
    ADCIN 0, D
    Check the datasheet. You might notice something wrong here!

    This next tip might make it a bit easier for you in the future. Using DEC vs. using # keeps the length of the decimal output to the LCD (the number of characters sent) constant, regardless if it's zero (one character) or 9999 (4 characters).

    That way you don't see 1000, when you actually want to see 0001.

    LCDOUT $FE,$C0, "Chase Speed " ,DEC4 D

  5. #5
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Code:
    with 10K pot set to RA1.
    
    ADCIN 0, D
    Check the datasheet. You might notice something wrong here!
    Whoops !
    Code:
    ADCIN 1, D

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c View Post
    Whoops !
    Code:
    ADCIN 1, D
    Working now?

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Yup !

    Thanks,

    And on that note as its gone midnight I'll give my brain a rest and get some sleep !

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Talking

    Quote Originally Posted by malc-c View Post
    Yup !
    Thanks,
    And on that note as its gone midnight I'll give my brain a rest and get some sleep !
    Ya right! Now that you got it working....do you actually think you're going to get some sleep at all?

Similar Threads

  1. Bitwise operations and masks: basics, help?
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 19th April 2008, 00:24
  2. IR software & hardware basics
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 6th May 2007, 10:05
  3. basics programming
    By olivierb38 in forum General
    Replies: 3
    Last Post: - 18th February 2007, 18:56
  4. Timers, oscillators, cycles... need basics please
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th October 2006, 18:33
  5. SERIN basics
    By Michael in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th August 2006, 18:37

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