Pic and programming

Discussion in 'Embedded Systems and Microcontrollers' started by joga316, Jan 30, 2010.

  1. joga316

    Thread Starter New Member

    Jan 30, 2010
    2
    0
    I've been doing circuits for awhile and have been learning a lot. Now i'm trying to get into programming and microcontrollers and i'm not fully understanding it. I started first in learning C programming which i've made a few programs and I think I got the hang of it for a starter. I got a Velman K8048 for my starting kit and I got a pic16f627. I have Bloodshed for my compiler.

    I've downloaded a hex which I can upload with no problem to the pic and used perfectly.

    My question is how do you program C into a microcontroller. I can make computer programs but how does it work with pics. How to you determine what which port/pin does what? Would i have to make a special header file for each pic that I use so it can work?

    Any help please!! Thank you for your time in reading and help!
     
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    You can make your own header file for each and assing names to all the control registers and special built in fucntions. However, there are C compilers which have already this header files made. Such compilers are the CCS compiler, the Hi-tech compiler, MikroC etc. I think you can download a limited free version of CCS from www.microchip.com. These compilers convert the C code in hex and then you can upload it to the PIC. If you want you can use assembly and MPLAB which is provided for free by Microchip.
     
  3. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    2,912
    2,178

    Here is a example of C using C18/MPLAB IDE (microchip) and a 18f8722 chip. This is for a solar charging station I'm working on. It's early prototype version of the software.
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    I like the Htsoft C compiler. You can get the lite version free. Htsoft is now owned by microchip. The lite version do not have any memory limitations like the CCS compiler. download it from www.htsoft.com For a beginner I think both CCS and Htsoft compiler will do fine.
    Ps Should your K4048 for some reason break down. Do not replace it with a new one. Get a PICKIT unit instead. They are much better
     
  5. joga316

    Thread Starter New Member

    Jan 30, 2010
    2
    0
    I've been seeing that the pickit is a lot better and that will be my next upgrade. Thank you all for helping me on this.
     
  6. KansaiRobot

    Active Member

    Jan 15, 2010
    318
    5
    well, i am a total beginner my self but this forum has helped me a lot so let me say a few words.

    First, you should download MPLAB IDE. I think it gives you the option of downloading C-compilers as well. however I have used only the MPLAB C18 lite compiler which I downloaded and installed it separatedly. When I installed it I made sure that MPLAB IDE will work with it as well

    After that you dont need Bloodshed. Program and compile directly on MPLAB IDE. The pins are detailed in the manuals. There are registers that you have to set to determine for example if a pin is input or output among other things

    header files for every model are provided by the compiler library

    Hope this helps.

    Kansai
     
  7. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Just a tip. If your PIC has any analog functions like AD or comparator, you must turn this off before you can use the ports assigned to these functions as digital input. They will work as digital output, but behave strange in bit operations. By default the analog functions are turned on after power on. For your PIC you should read very careful about the CMCON register.
     
Loading...