building own library with include-files?


Results 1 to 26 of 26

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    Then it looks like I'm only half done with you Steve.

    Oh, and sorry about that disease. A little penicillin and you'll be fine.

    So, let's see. More reasons to use Include files...

    Hardware Definition:
    How many proto-boards do you have on your bench?  Or on a shelf somewhere?  At the very least, just for trying out everyone elses programs you would need 2.   1 for 14-bit programs, and 1 for 18F's.  Maybe even a 12F proto in the mix. Personaly, I have 7.

    Now, how many times have you Cut&Pasted the hardware definition section from some other program you wrote, just to have all the __configs, crystal, and pinout information so you could try out some little piece of code thats only 10 lines. And how long did it take to find the program that had the right definitions in the first place.

    What I'm suggesting is to have a Hardware Definition file for each proto-board which defines everthing required to initialize that device, the LCD, USART, EEPROM's and give meaningfull names to the pins, SDA, SCL etc.

    Now whenever you want to try the program on a different chip, simply INCLUDE the file for the proto-board you want to use, and spend your time on the program, instead of trying to get it to run on that hardware.  Then if you change the hardware (it is a proto-board), you only need to change 1 file.  And, you won't be copying the wrong header from an old file.

    Here's 1 of my definition files, it's nothing special, just the basics for a LAB-X2. This way all I need to do is <p>INCLUDE "\PBP\hardware\LAB-X2.DEF"</p>and everthings ready to go, just add program.
    Code:
    '****************************************************************
    '*  Name    : C:\LAB-X2.DEF                                     *
    '*  Author  : Darrel Taylor                                     *
    '*  Date    : 5/8/2003                                          *
    '*  Version : 1.0                                               *
    '*  Notes   : Target is 18F452                                  *
    '*          :                                                   *
    '****************************************************************
     @ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H	' Set oscillator to High Speed (HS)
     @ __CONFIG _CONFIG2H, _WDT_OFF_2H					' Turn off Watch Dog Timer (WDT)
    
    Define OSC 10
    CLEAR
    
    
     ' Define Hardware PWM channel 1
    DEFINE  CCP1_REG		PORTC
    DEFINE  CCP1_BIT		2
    
    ' Define Hardware PWM channel 2
    DEFINE  CCP2_REG		PORTC
    DEFINE  CCP2_BIT		1
    
    AnalogPot    VAR  PORTA.0
    AnalogPotAN  CON  0
    
    ADCON1 = $8E      ' Right Justified, AN0 (RA0) Analog
    
    INTCON2.7  = 0    ' Enable PORTB Pull-Ups
    
    Button1  VAR PORTB.4
    Button2  VAR PORTB.5
    Button3  VAR PORTB.6
    
    Servo    VAR PORTB.3
    
    LED1     VAR PORTB.0
    LED2     VAR PORTB.1
    LED3     VAR PORTB.2
    
    LOW LED1
    LOW LED2
    LOW LED3
    That's just one more reason. I have more.
    <br>
    Last edited by Darrel Taylor; - 15th September 2005 at 07:10.
    DT

Similar Threads

  1. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 21:42
  2. Can't seem to add AllDigital to the include files
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th November 2009, 04:21
  3. Missing 16F882 family include files :-(
    By campmdabt in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 27th December 2007, 01:17
  4. include files 8k limit
    By skimask in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th January 2006, 06:35
  5. Replies: 2
    Last Post: - 13th December 2005, 00:11

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