Chipselect Var PORTD,Vecto4X Compass


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2004
    Location
    nebraska
    Posts
    79

    Default Chipselect Var PORTD,Vecto4X Compass

    Can a person use the alias for Chipselect Var PORTD and select only 3 bits or pins of PortD. I know you can do the whole PortD or just 1 bit, but how if possible would you assign only the 3 MSB to chipselect.

    I could not find it in the PBP manual.


    Also has anyone messed around with the vector 4X digital compass, if so a little code would be helpfull.

    Thanks A Bunch

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Shawn,

    Yeah, that would be handy. Too bad you can't do it.

    But there's a way to handle it when Reading/Writing to the port.

    Writing to the Port:
    Code:
    Chipselect   VAR  Byte
    
    Chipselect   = 2
    PORTD = PORTD & %00011111 | (Chipselect << 5)
    It first reads the current value of PORTD, then AND's it with a mask %00011111 to leave the unused bits alone, then OR's it with the Chipselect value after it's been shifted left 5 places.

    So, the range of Chipselect is 0 to 7, and it gets re-mapped to the 3 MSB of PORTD

    Reading from the Port:
    Code:
    Chipselect   VAR  Byte
    
    Chipselect  = PORTD >> 5
    Reading is easier, just shift the contents of PORTD 5 bits to the right.

    HTH,
    &nbsp;&nbsp;&nbsp;Darrel
    Last edited by Darrel Taylor; - 25th January 2005 at 06:42.

  3. #3
    Join Date
    Dec 2004
    Location
    nebraska
    Posts
    79


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel

  4. #4
    Join Date
    Nov 2005
    Posts
    19


    Did you find this post helpful? Yes | No

    Default How to do ARCTAN (inverse tan) in PICBasic Pro

    Arctan() is a trigonometric function. It is the inverse function of the tangent function, tan(). That is,

    tan(x) = y implies arctan(y) = x ; for all x

    How to do the arctan operation in picbasic pro?

    TQ

Similar Threads

  1. RF Modules
    By tonyfelloni in forum mel PIC BASIC Pro
    Replies: 44
    Last Post: - 26th June 2010, 17:42
  2. RS485 bus - starting probem
    By wurm in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 27th January 2010, 13:35
  3. Puzzling issue with I2CWRITE to 24LC512
    By aberco in forum General
    Replies: 4
    Last Post: - 22nd August 2008, 17:47
  4. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47
  5. 18F6680 and portd problems.
    By jkbh in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2005, 10:54

Members who have read this thread : 1

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