PBP3, PICkit2, MPLAB IDE v8.83, MCSX, and I am baffled.

Discussion in 'Embedded Systems and Microcontrollers' started by tracecom, May 2, 2012.

  1. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    I have the stuff listed in the title and a Low Pin Count Demo board. I have successfully programmed PICAXE MCU's, but I am very confused about the process of programming PIC's.

    Here's what I think I know.
    1. I use MPLAB IDE or MCSX to start the whole process.
    2. I use PBP3 (via the IDE) to write the code.
    3. I use MPASM (via the IDE) to create the machine code and download it to the PIC.

    So far, I have written a couple programs in assembler that turn on a single LED, but I don't seem to be able to penetrate PBP3.

    I have a small selection of PIC's: 12F629, 12F509, 16F505, 16F506, 12F629, 16F684, and 16F628A. If I had a piece of PBP3 code that was written specifically for my Low Pin Count Demo board that I could compile, run, and study, maybe I could start to understand what I am doing.

    Any help would be appreciated. Thanks in advance.
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Last edited: May 2, 2012
  3. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Thanks. I have downloaded and installed HI-TECH C in the lite mode, and have the 16F628A in the Low Pin Count Demo Board.
     
  4. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Ok. Are you able to connect the PICkit2 to the 16F628A and run the LED demo program?
     
  5. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    There is no LED demo program on the 16F628A; I bought it from Digi-key. There is a demo program on the 16F690 that came with the demo board, and I was able to run that.
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    I know. Your chip is blank.

    I don't have my computer here with me but there should be an LED demo program when you downloaded the Hi-Tech C software.

    Anyhow, we can roll our own.

    Are you able to fire up Hi-Tech C?
     
  7. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    When I try to start it directly from Windows, it prompts me to select lite or buy, I make the lite selection, and click finish, but it doesn't start. Should I be calling it from MPLAB IDE?
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Yes. Start with MPLAB IDE.
    Under Project, Open...
    See if you can find an LED project. If not I will send you the code for you to cut and paste.

    If you cannot find any demos,
    go to Project, Project Wizard and follow the instructions.
    I will try to lead you along or someone else would like to help out.
     
  9. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    I found this code.

    Code ( (Unknown Language)):
    1. #include <htc.h>
    2. /*
    3.  * Demo program
    4.  *
    5.  * Flashes LEDs on Port B, responds to switch press
    6.  * on RA1. Usable on PICDEM board.
    7.  *
    8.  * Copyright (C)1997 HI-TECH Software.
    9.  * Freely distributable.
    10.  */
    11. #define BUTTON RC1 //bit 1 of PORTC
    12. main(void)
    13. {
    14.  unsigned char i, j;
    15.  TRISB = 0;  /* all bits output */
    16.  j = 0;
    17.  for(;;) {
    18.   PORTB = 0x00;  /* turn all on */
    19.   for(i = 100 ; --i ;)
    20.    continue;
    21.   PORTB = ~j;  /* output value of j */
    22.   for(i = 100 ; --i ;)
    23.    continue;
    24.   if(BUTTON == 0)  /* if switch pressed, increment */
    25.    j++;
    26.  }
    27. }
    28.  
    When I select PICkit2 as the programmer, I get this message.

    PKWarn0003: Unexpected device ID: Please verify that a PIC16F628A is correctly installed in the application. (Expected ID = 0x1060, ID Read = 0x3FE0)

    ETA: I have to go out for about an hour or so (starting at 6:40 pm central time.)
     
    Last edited: May 2, 2012
  10. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    OK. I don't know if you opened a project (.mcp) or just the led.c file.
    Copy this source code to the clipboard or to the NotePad.
    Create a folder in C:\ and call it something like PIC.
    Save this demo file in C:\PIC\led.c

    Quit MPLAB IDE and start over again. We will create a new project.

    From MPLAB, Project, Project Wizard.
    I will try to follow along. I have my laptop but no PICkit2.
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    When you get to the Project Wizard
    Select the Device: PIC16F628A
    Select Active Toolsuite: HI-TECH Universal ToolSuite
    Create New Project File: browse to your directory C:\PIC
    enter Filename: ledtest
    Add>> C:\PIC\led.c

    Finish!

    In the project window ledtest.mcw
    double click on led.c to view and edit the source code.
     
    Last edited: May 2, 2012
  12. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    delete (or comment out the following lines using // at the start of the line)

    Code ( (Unknown Language)):
    1.  
    2. #define BUTTON RC1
    3.  
    4. if(BUTTON == 0)
    5.  
    6.  
    Under Debugger, Select Tool, 7 PICkit2

    You will see on the top bar, a black square and a red square.
    Click on the black square.


    Edit:

    Oops, some incompatibility with the Low Pin Count Board. More to come.
     
    Last edited: May 2, 2012
  13. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    The PIC16F628A-I/P is an 18-pin DIP.
    The Low Pin Count Board has a 20-pin socket.
    As far as I can see the pin outs are not the same. We will have to work around that, unless someone else chimes in.

    Do you have a solderless breadboard we can use instead?
    And a 6-pin header that fits into the PICkit2 ICSP?
     
  14. whatsthatsmell

    Active Member

    Oct 9, 2009
    102
    4
    The Low Pin Count Demo Board should have come with a 16F690 chip (20 pins).
     
  15. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    OK, I am back.

    The pin-out on the 16F628A is totally wrong for the Low Pin Count Demo board. I probably ruined it by putting power on pin 1 and ground on pin 18.

    Yes, I have a solderless breadboard and can rig up something, but that introduces another set of potential errors (my wiring) that may further complicate the issue. Maybe we should use one of the 8 or 14 pin PICs that I have? Or, I could put the 16F690 back in? I would rather use the Low Pin Count Demo Board, but you tell me.
     
  16. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    You are correct. It did, and I have had it running with the demo code that came on it.
     
  17. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Ok. Go to Configure, Select Device, Device: PIC16F690
    I have to go look at the pin out for the PIC16F690.
     
    Last edited: May 2, 2012
  18. tracecom

    Thread Starter AAC Fanatic!

    Apr 16, 2010
    3,869
    1,393
    Initializing PICkit 2 version 0.0.3.63
    Found PICkit 2 - Operating System Version 2.32.0
    Target power detected ( 4.33V)
    PIC16F690 found (Rev 0x6)
    PICkit 2 Ready
     
  19. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Or if you want to save that preprogrammed PIC16F690
    you can try one of your 14-pin chips PIC16F684
     
  20. whatsthatsmell

    Active Member

    Oct 9, 2009
    102
    4
    Back to your initial post - did you want to learn PicBasic Pro specifically, or are you just trying to pick up any language?

    With your background in Pic Axe, PBP should be pretty easy to pick up.

    C is also a good choice; a little harder to learn, but you will find a lot more support here with C. You can also use it with other brands of microcontrollers.

    I can help you get started with PBP if you want to go that way, and it looks like Mr Chips is getting you going with C.
     
Loading...