Tips to start programming pics

Discussion in 'Embedded Systems and Microcontrollers' started by Ironic, Dec 23, 2008.

  1. Ironic

    Thread Starter Member

    Dec 23, 2008
    10
    0
    it´s been a few years since i programmed in assembly, and i am now in a position where i need to do a few projects envolving pics.
    my doubt now is between programming in assembly or C.

    My idea is that assembly is better by one side, because it allows more control over what we are doing, while C (that i know well) would allow to write bigger programs a lot faster.
    My question about C, is if it is possible to access some of the special features of chips, like watchdog timer,pwm and generating interrupts from signal changes on ports.
    I could only find simple c guides that did not cover this points.

    was hoping for some advice on this. Tks
     
    Last edited: Dec 23, 2008
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    C is a good choice for programming the PIC. You may find it a wee bit expensive.

    If you like FREE then you may want to consider the ATMEL AVR since the Assembly Language and the C-Language programming tools are free and very powerful.

    By the way C compilers support the low level hardware features of the PIC or the AVR microcontrollers.

    hgmjr
     
  3. Ironic

    Thread Starter Member

    Dec 23, 2008
    10
    0
    can you point me to some site or literature were the low level hardware features os pics are explained trough C? tks
     
  4. futz

    Member

    Dec 14, 2008
    23
    0
    Assembly gives you cycle-accurate fine control, which is pretty much impossible in C. But you can use inline assembly code inside C to do the same thing for the time-critical part. This isn't something you'll do very often, but sometimes it's necessary.

    For everything else C is great! You have full access to all MCU features, same as in asm. Timers, PWM, interrupts, ports, etc. are all just as accessible as in asm. No problem there.

    I love assembly language programming, but C makes things so much quicker and easier. Also, C programs, especially bigger ones, are SO much easier to read/understand, especially when you've not looked at the source for a long while.

    If you're going to be programming PICs in C, I highly recommend SourceBoost BoostC. The demo is only code size/RAM limited - works for all supported PICs. And when you hit the limits of the demo, a full license for the compiler is only about $75! Compare with C18's price of ~$500 and PICC's price of ~$1000. It's a no brainer! Better yet, BoostC comes with both 16F (supports some 12F also) and 18F compilers.
     
    Last edited: Dec 23, 2008
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Here is a link to a website that shows some code samples for the free AVR C-compiler called WINAVR.

    This C compiler works with pretty much the entire AVR family of microcontrollers.

    Did I mention it was free?

    hgmjr
     
  6. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You can download the assembler AVRSTUDIO4 at www.atmel.com and check it out right now.

    You will be surprised at its power. It is full-featured without any limitations.

    hgmjr
     
  7. Ironic

    Thread Starter Member

    Dec 23, 2008
    10
    0
    tks, but i prefer using pics. already a bit familiarized with them, and have a programmer.

    all i need is some guides on using C with those features. tks
     
  8. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    Which PIC are you thinking of? For 18F the C18 from Microchip is free, except for one disabled code optimisation option (not really a big deal for most project). The help file included is informative enough to get you going.

    The idea is the same with assembler, the peripherals are controlled through Special Function Registers by writing or reading the values. For example, to load the timer, in assembly it would be:

    movlw 0x40
    movwf TMR0

    In C it would be:

    TMR0 = 0x40;

    As you can see, the procedure is exactly the same only the syntax is different. The datasheet would have complete information on how to control and access all available peripherals.
     
  9. abhijeetscience

    New Member

    Dec 24, 2008
    4
    0
    i made many codes for picaxe how to convert for pic .. any software conversion available for it and can anyone explain the picone micromouse pcb board to me how the pcb connections and what is each made for speciallt the registers capacitors and the sensors :D
     
Loading...