constants


Closed Thread
Results 1 to 6 of 6

Thread: constants

  1. #1
    cmolson's Avatar
    cmolson Guest

    Default constants

    Hello, I am pretty new to picbasic and have some questions which should be pretty straight forward.

    I am writing a program to send data serially out using the debug command and have confirmed to be able to use 9600bps at 3.579mhz. I need to send the data in inverted form so this is the code I use to declare and invert a variable:

    A4 var byte
    A4=~$A4 REV 8

    Is there a way to do this using constants? I have a lot of bytes I need to do this with and I don't want to manually invert them by hand because they lose their meaning to people reading the code that way.


    I would like to do this for example:

    A4 CON ~$A4 REV 8

    The ~ inverts the bits, and the REV8 reverses it. However this does not compile. It only works when I declare it as a variable. Maybe i could use some kind of table and lookup method? Thanks!

  2. #2
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Why not convert them manually and comment each line so u know whats going on... e.g.:

    A4 CON $DA 'Inverted and Reversed $A4

  3. #3
    cmolson's Avatar
    cmolson Guest


    Did you find this post helpful? Yes | No

    Default

    wow, good idea thanks!. As all these variables will quickly eat up my ram space. I jsut wish it was easier for me to update the code later on without inversing stuff. Thansk for the quick reply!

  4. #4
    cmolson's Avatar
    cmolson Guest


    Did you find this post helpful? Yes | No

    Default

    One more question though, is it possible to make an array constant? I would like to make one with 9 byts in it. I'm not sure how to go about that. The bytes are hex.

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    No I dont think you can make an array constant. If you want an array you will have to use a variable like this:

    label VAR BYTE[length]

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by cmolson
    As all these variables will quickly eat up my ram space
    Why not using the internal eeprom instead?

    Code:
    ArrayIndex var byte
    ArrayData var byte
    
        ' PreLoad EEPROM at programming time
        ' ===================================
        '
    data @0,$10,$20,$30,$40,$50
        '
        '
        ' Read data from EEPROM
        ' =====================
        '
    Read ArrayIndex,ArrayData
    Usually that's what i do instead of using Array... well if the PIC have EEPROM and/or free EEPROM storage.

    Good luck!
    Last edited by mister_e; - 1st December 2005 at 13:35.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. The EXT (external) modifier.
    By Darrel Taylor in forum FAQ - Frequently Asked Questions
    Replies: 19
    Last Post: - 11th July 2010, 00:21
  2. How to define constants that specify eeprom addresses
    By DwayneR in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 8th December 2009, 04:07
  3. Problem with 16F648A
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th March 2008, 23:08
  4. PORTC constants
    By Forkosh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th October 2007, 05:43
  5. Bug ? Error in calculating constants
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th October 2005, 21:55

Members who have read this thread : 2

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