MPLAB help

Discussion in 'Programmer's Corner' started by vane, Aug 21, 2009.

  1. vane

    Thread Starter Active Member

    Feb 28, 2007
    181
    0
    I bought the June 09 issue of Elektor magazine with part 2 of Embedding C programming.

    I downloaded MPLAB but i can not get it to function properly

    I tried making a new project then added a file called main.c to the project and inset this code:
    Code ( (Unknown Language)):
    1.  
    2. void delay(unsigned int);
    3. void set_7segment(int, int );
    4. unsigned int t;
    5.  
    6. void main(void)
    7. {
    8.  
    9.     delay(100);
    10.     set_7segment(3,1)
    11.     ...
    12. }
    13.  
    14. void delay(unsigned int k)
    15. {
    16.     int i;
    17.     ...
    18. }
    19.  
    20. void set_7segment(int nr, int dp)
    21. {
    22.     ...
    23. }
    24.  
    25. if ((P1IN & BIT5)== 0)
    26. {
    27.     do
    28.     {
    29.         P1OUT |= BIT1;
    30.         delay(3);
    31.         P1OUT &= BIT1
    32.         delay(3);
    33.     }
    34.     while(P1IN & BIT6);
    Can anyone help me on this subject?

    EDIT: BTW i managed to set it to PIC16F627
     
  2. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    What C compiler are you using with MPLAB? MPLAB itself only comes with assembler, there is a separate download for C18 compiler, which supports PIC18 only. To program PIC16 with C you need to additional C compiler, such as CCS or Hi-Tech. These are pay for software, but you could download the limited evaluation version if you wish.
     
  3. vane

    Thread Starter Active Member

    Feb 28, 2007
    181
    0
    Thats is pretty stupid :s
     
  4. vane

    Thread Starter Active Member

    Feb 28, 2007
    181
    0
    ah, when i was installing it gave me the option of installing HI-TECH C or something like that, would that be what i need?
     
  5. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    Yes.

    [padding]
     
  6. vane

    Thread Starter Active Member

    Feb 28, 2007
    181
    0
    any idea on how to operate it?
     
  7. n9352527

    AAC Fanatic!

    Oct 14, 2005
    1,198
    4
    No. I've never used Hi-Tech compiler. I use C18 on 18F, and assembly for other devices. But the procedures should be similar. Choose the tools from the menu and select the compiler on the dialog box. There should be a help file coming with the compiler. And 'How to Get Started' example.
     
Loading...