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

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
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.
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
All you need is PICkit2.
Go to MicroChip.com website and download Hi-Tech C:

I will post the link once I can get through.

We can start off with the 16F628A.
Thanks. I have downloaded and installed HI-TECH C in the lite mode, and have the 16F628A in the Low Pin Count Demo Board.
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
Ok. Are you able to connect the PICkit2 to the 16F628A and run the LED demo program?
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.
 

MrChips

Joined Oct 2, 2009
30,701
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?
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
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?
 

MrChips

Joined Oct 2, 2009
30,701
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.
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
I found this code.

Rich (BB code):
#include <htc.h>
/*
 * Demo program
 *
 * Flashes LEDs on Port B, responds to switch press
 * on RA1. Usable on PICDEM board.
 *
 * Copyright (C)1997 HI-TECH Software.
 * Freely distributable.
 */
#define BUTTON RC1 //bit 1 of PORTC
main(void)
{
 unsigned char i, j;
 TRISB = 0;  /* all bits output */
 j = 0;
 for(;;) {
  PORTB = 0x00;  /* turn all on */
  for(i = 100 ; --i ;)
   continue;
  PORTB = ~j;  /* output value of j */
  for(i = 100 ; --i ;)
   continue;
  if(BUTTON == 0)  /* if switch pressed, increment */
   j++;
 }
}
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:

MrChips

Joined Oct 2, 2009
30,701
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.
 

MrChips

Joined Oct 2, 2009
30,701
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:

MrChips

Joined Oct 2, 2009
30,701
delete (or comment out the following lines using // at the start of the line)

Rich (BB code):
#define BUTTON RC1

if(BUTTON == 0)
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:

MrChips

Joined Oct 2, 2009
30,701
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?
 

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
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?
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.
 

MrChips

Joined Oct 2, 2009
30,701
Ok. Go to Configure, Select Device, Device: PIC16F690
I have to go look at the pin out for the PIC16F690.
 
Last edited:

Thread Starter

tracecom

Joined Apr 16, 2010
3,944
Ok. Go to Configure, Select Device, Device: PIC16F690
I have to go look at the pin out for the PICF690.
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
 

whatsthatsmell

Joined Oct 9, 2009
102
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.
 
Top