+ Reply to Thread
Results 1 to 7 of 7

Thread: PIC18 C Help

  1. #1
    Spideys Newbie
    Join Date
    Nov 2009
    Location
    Johannesburg, South-Africa
    Posts
    4

    Default PIC18 C Help

    Good Day all

    This is my first post. I am in need of serious help. I am willing to read up on the info np, but i cant seen to find exactly what I am looking for:

    C language, instructions, symbols & syntax for PIC18

    I am working on a Smart Battery charging unit that i want to control using a PIC microcontroller.

    Just want to get some basics up and running before i start design.

    Like example how do i read the state of an input pin ( correctly setup RA0) using C language and PIC18f4331 or PIC18f4520

    Any help would be much appreciated ( Going insane here )


  2. #2
    Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent Pommie Excellent
    Join Date
    Mar 2005
    Location
    Brisbane Australia
    Posts
    6,805

    Default

    There are many examples of C18 code on this site. If you look at my profile and the threads I have started, some are C18 related.

    To check RA0 you would do,
    Code:
        if(PORTAbits.RA0==1){
            //code here
        }
    
    Mike.

  3. #3
    AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent
    Join Date
    Feb 2008
    Location
    Brooklyn, NY US
    Posts
    3,744

    Default

    if you are using C18 from microchip then when its installed goto

    C:\mcc18\doc

    there are a few documents there with lots of info:

    hlpC18Lib.chm - "This section gives an overview of the MPLAB C18 library files and precompiled object files that can be included in an application"

    hlpC18ug.chm
    - "This document discusses the technical details of the MPLAB C18 compiler. This document will explain all functionality of the MPLAB C18 compiler"

    hlpPIC18ConfigSet.chm - "This document lists the configuration settings available for each of the PIC18 devices for use with MPLABŪ C18's #pragma config directive and MPASM™ assembler's CONFIG directive. "

    PIC18F Peripheral Library Help Document.chm - "The PIC18 MCU Peripheral Library provides a set of functions for setting up and controlling the operation of all the peripheral modules available in the PIC18 devices, as well as functions for interfacing with an external LCD, Software implemented communication modules. "
    AtomSofts eBay Store
    AtomSoftTech: C18 TIPS & TRICKS v9 PDF

    My Name: Jason Lopez
    My BLOG | My YouTube Videos!
    My Favorite Store:
    dipmicro Electronics
    Trading and Selling...? Check out Dipmicro Trading/Selling Forum:
    Electronic Components & Tools Exchange

  4. #4
    Spideys Newbie
    Join Date
    Nov 2009
    Location
    Johannesburg, South-Africa
    Posts
    4

    Default

    Thanx AtomSoft
    Thanx Pommie...

  5. #5
    AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent
    Join Date
    Feb 2008
    Location
    Brooklyn, NY US
    Posts
    3,744

    Default

    no problem there are a select few here who would help you out a lot if you ask right and actually try to learn yourself also.

    If you have a project in mind post about it and post your progress this way we know your intentions are for help not just someone to do it all for you.

    pommie code is correct but there are more efficiant ways like define the port pin this way if it needs to be changed you only need to change one line and all will follow:

    Code:
    #define myButton PORTAbits.RA0
    
    .....
    
    //now you can use 
    if(myButton == 1){
        //button pressed do something
    }
    
    Note: the above code assumes the button is pulled down meaning a resistor is connected to GND.

    If your button is pulled high then use the below code:

    Code:
    #define myButton PORTAbits.RA0
    
    .....
    
    //now you can use 
    if(myButton == 0){
        //button pressed do something
    }
    
    AtomSofts eBay Store
    AtomSoftTech: C18 TIPS & TRICKS v9 PDF

    My Name: Jason Lopez
    My BLOG | My YouTube Videos!
    My Favorite Store:
    dipmicro Electronics
    Trading and Selling...? Check out Dipmicro Trading/Selling Forum:
    Electronic Components & Tools Exchange

  6. #6
    Slorn Newbie
    Join Date
    Oct 2009
    Posts
    10

    Default

    Hi

    Lots of great tutorials and C18 code examples can be found here:
    http://www.dwengo.org/tutorials

    It starts with blinking a LED and goes up to building robots using a PIC18.

    Have fun with it!
    Slorn
    Last edited by Slorn; 19th November 2009 at 10:22 PM.

  7. #7
    AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent AtomSoft Excellent
    Join Date
    Feb 2008
    Location
    Brooklyn, NY US
    Posts
    3,744
    AtomSofts eBay Store
    AtomSoftTech: C18 TIPS & TRICKS v9 PDF

    My Name: Jason Lopez
    My BLOG | My YouTube Videos!
    My Favorite Store:
    dipmicro Electronics
    Trading and Selling...? Check out Dipmicro Trading/Selling Forum:
    Electronic Components & Tools Exchange

+ Reply to Thread

Similar Threads

  1. PIC18 tutorials
    By yohanevindra in forum Micro Controllers
    Replies: 4
    Latest: 15th November 2009, 05:53 AM
  2. PIC18 and keypad
    By yohanevindra in forum Micro Controllers
    Replies: 8
    Latest: 15th October 2009, 10:47 AM
  3. Pic18 in C and Parallax GPS
    By zBusterCB87 in forum Robotics Chat
    Replies: 1
    Latest: 13th October 2009, 03:48 PM
  4. reading gps with pic18
    By pawnda in forum Micro Controllers
    Replies: 12
    Latest: 14th September 2009, 09:04 AM
  5. PIC18 Grounding
    By col_implant in forum Micro Controllers
    Replies: 3
    Latest: 26th February 2008, 03:59 PM

Tags for this Thread