Discussion in "PIC Microcontroller Discussion" started by    kingrosekhan123    May 11, 2013.
Sat May 11 2013, 02:34 pm
#1
Hello Experts..
i am using MPLAB 8.89 with HI TECH compiler 9.80.

i listen from some people about LIBRARIES for PIC.that they make ease for them.

can anyone tell me that how to use these libraries and from where it can download..??
because i see that its avoid from written many lines in coding and you get good results with precision .

please help me in this way.
Sat May 11 2013, 03:03 pm
#2
for which PIC do you want libraries???? is it for PIC18 series or PIC16 series???
Sat May 11 2013, 11:37 pm
#3
Yi am using pic18f458...
Sun May 12 2013, 12:51 pm
#4
Check this link...
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014

 kingrosekhan123 like this.
Sun May 12 2013, 01:43 pm
#5
its C18 compiler.

i want to download libraries.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en547784
check this link . i download from here a setup of 330mb .it contain usb ,graphic and etc library..

i installed but i dont know how to use.

Mon May 13 2013, 10:47 am
#6
well those libraries have sample projects which you can directly use or those codes you can copy in your working project and make use of them. There is a proper documentation provided with each project. like application notes etc. rest of the information you can get from source file what exactly they are doing.
Wed May 15 2013, 08:49 pm
#7
this is the code for 1sec delay.now i want that in main function i just call delay not to type these lines ,and in future i make it useable in my other codes.

kindly help me.

//Timer0
//Prescaler 1:32; TMR0 Preload = 3035; Actual Interrupt Time : 1.000001 s

unsigned onesec = 0;

//Place/Copy this part in declaration section
void InitTimer0(){


T0CON	 = 0x84;

TMR0H	 = 0x0B;

TMR0L	 = 0xDB;

INTCONbits.GIE	 = 1;

INTCONbits.TMR0IE	 = 1;

}


//Timer0
//Prescaler 1:32; TMR0 Preload = 3035; Actual Interrupt Time : 1.000001 s


//Place/Copy this part in declaration section
void interrupt isr0(void){


if (INTCONbits.TMR0IF){

INTCONbits.TMR0IF = 0;

TMR0H	 = 0x0B;

TMR0L	 = 0xDB;
onesec++;


//Enter your code here

}

}



#define LED LATBbits.LATB0


void main(){

    TRISB = 0x00;
    PORTB = 0x00;
    InitTimer0();
    while(1){


       if(onesec == 1){

           onesec = 0;
           LED = ~LED;
       }
    }

}
Thu May 16 2013, 05:13 pm
#8
Library means it should be usable and configurable, less hardware dependency on specific hardware peripheral etc. Interrupt should be avoided strictly as it adds hardware dependent code.

If you are writing a delay library then, basic functions should be:

1. initdelaylib(): a function to initialize library, where you can pass which timer to use, what is the clock frequency so that you can calculate your timer pre scalers etc.
2. msleep(): function for delay in ms
3. sleep(): function for delay in seconds

a sample prototype would be
unsigned char initdelaylib(unsigned char timerused, unsigned long oscclock);


Your main function will look like this:

void main () {
        initdelaylib(0, 8000000UL); /* Timer 0 used, osc clock is 8Mhz */
        while (1) {
                LED = ~LED;
                sleep(1);
        }
}


I hope you understood the basic concept of having a library. In simple words, it should be easily portable, usable and configurable.
 kingrosekhan123 like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am