PICKIT3 Debug Express Question

Thread Starter

blah2222

Joined May 3, 2010
582
Hello,

I recently purchased the PICKIT3 Debug Express Development Kit with the 44-pin PIC18F45K20 and I just booted the CD and installed MPLAB.

I wanted to get right into the lessons so I setup "Lesson 1: Hello LED". First thing that I notice is that the C18 compiler does not come preloaded which isn't that bad, but for a beginner, this might throw them off. So, I downloaded the C18 Lite version and installed it. That's all fine now.

So now I add the "01 Hello LED.c" source file and the "18f45k20.h" header file and that's all smooth sailing, until I come to finding the linker file. In the lesson, they specify to use the "18f45k20_i.lkr" file but looking through my C18 bin directory, all the I have is the "18f45k20_g.lkr" file.

I know it's probably a quick fix, but after spending $70 would it kill Microchip to just preload everything?
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
Yes linker files are necessary, how else would you link the code? <grin>

AFAIK the C18 compiler doesn't need the specific link script included in the project, so if you have something under "Linker Script" in the MPLAB workspace remove that reference (highlight in workspace & hit delete, the file is still there but not added to your project).

The next step is important and a bit of a PITA: you need to know the folder you installed the C18 compiler in, mine is in C:\MCC18. On MPLAB's menu hit Project | Build Options | Project and get the "Directories" tab. You need to tell it the Include Search Path has C:\MCC18.h and the Library Path has C:\MCC18.lib.

Then it should build and link clean. I had to do this little bit of annoyance everything I started a new C18 project.

(Don't worry what "linking" means for a while, you'll get there when it is time.)
 

Thread Starter

blah2222

Joined May 3, 2010
582
Thanks again ErnieM!

Yeah, I figured they would link automatically or something, but I just find it so strange that I don't have the "18f45k20i.lkr" file anywhere. Such a PITA for beginners as you can't run the lessons on first startup.

:mad:
 

Thread Starter

blah2222

Joined May 3, 2010
582
Also, when I purchased this kit, it said that there were going to be 12 Assembly lessons that would be provided. All I see are 12 C18 lessons and lesson guide for C18. Anyone know what happened to the PIC18F45K20 Assembly lessons?

Thanks
 

ErnieM

Joined Apr 24, 2011
8,377
Anyone know what happened to the PIC18F45K20 Assembly lessons?
I believe that was from the earlier version of the PicKit2. PIC18's are quite cumbersome to program in assembly. I believe the assembly routines were for a PIC12 or PIC16 core.

I had them and can't find them now, they are probably just on my work computer. I zipped them up and posted them on here a few weeks back but I can't find that post either.

I'm just lost....

Edit: FOUND 'EM
 
Last edited:

Thread Starter

blah2222

Joined May 3, 2010
582
I believe that was from the earlier version of the PicKit2. PIC18's are quite cumbersome to program in assembly. I believe the assembly routines were for a PIC12 or PIC16 core.

I had them and can't find them now, they are probably just on my work computer. I zipped them up and posted them on here a few weeks back but I can't find that post either.

I'm just lost....

Edit: FOUND 'EM
Sweet, thanks! I was really hoping Microchip had some PIC18 assembly lessons like the package said it would contain... Oh well.

Also, is there a way to convert my C18 file into Assembly file?
 
Last edited:

t06afre

Joined May 11, 2009
5,934
I believe that was from the earlier version of the PicKit2. PIC18's are quite cumbersome to program in assembly. I believe the assembly routines were for a PIC12 or PIC16 core.

I had them and can't find them now, they are probably just on my work computer. I zipped them up and posted them on here a few weeks back but I can't find that post either.

I'm just lost....

Edit: FOUND 'EM
Those lessons are for a PIC16f690. So some modification is needed in order to make them work on a 18F series PIC. But It could be a good lesson to do just that. You can ask us for help if you need
 

ErnieM

Joined Apr 24, 2011
8,377
Sweet, thanks! I was really hoping Microchip had some PIC18 assembly lessons like the package said it would contain... Oh well.

Also, is there a way to convert my C18 file into Assembly file?
Yeah, the sales documentation didn't catch up with the hardware. The sales guys would never understand what they are selling anyway. When I got my Pickit 2 w/ board it was a PIC16.

I never tried to do assembly in a PIC18 (or higher), just too many modes and was never strongly motivated to learn it as by the time I started using 18's I had a wonderful compiler to use.

I don't know where it is but there should be a compiler switch in the C compiler to produce an .asm file output, as it is writing an asm program anyway, right?

If nothing else, you can always click View | Disassembly Listing in MPLAB
 

Thread Starter

blah2222

Joined May 3, 2010
582
Cool, just viewed the Disassembly and it seems a lot more complicated. Hmm, I think for PIC18 I'll stick with C18 and I'll learn Assembly with my PIC16F84A. I'll just have to figure out how to program it with the PICKIT3...

There is a good tutorial I came across for the PIC16F84, (which I believe is no longer produced). I'm hoping the 16F84A is just a drop and place replacement.

Do you guys have any experience with programming a PIC16 with the PICKIT3?

Thanks again!
 

t06afre

Joined May 11, 2009
5,934
It is the same thing programming all PICs that support ICSP. Just hook up your programmer (given that it support the chip). And program it. The PICKIT 3 works in the same way. For the 16F series as the 18F series. Just get the 5 wires needed correct from the PICKIT correct.
One last note if you can avoid it, do not use the 16f84 chip. It is much like the LM741 opamp. It refuse to die
 

Thread Starter

blah2222

Joined May 3, 2010
582
It is the same thing programming all PICs that support ICSP. Just hook up your programmer (given that it support the chip). And program it. The PICKIT 3 works in the same way. For the 16F series as the 18F series. Just get the 5 wires needed correct from the PICKIT correct.
One last note if you can avoid it, do not use the 16f84 chip. It is much like the LM741 opamp. It refuse to die
lol ok, so what do you think about the 16F84A?
 

t06afre

Joined May 11, 2009
5,934

Thread Starter

blah2222

Joined May 3, 2010
582
Hey just another quick question. I was playing around with some sample code Microchip gave me and it was all working until I tried a few values.

I just wanted to light up all 8 LEDS, (connected to PORTD), and just run an infinite loop, so without looking at config bits here is what I thought would work:

Rich (BB code):
#pragma code

void main (void)
{
   TRISD = 0x00; //all bits are outputs
   LATD = 0xFF; //all bits are high (all LEDs on)

   while (1)
   {
      ;
   }
}
Now, I am expecting that all the LEDs should turn on, but none of them turn on. I have tried 0xFE and numerous others and sometimes they have all their corresponding LEDs on and sometimes I get nothing at all. Does anyone know how to fix this?

Might the latch be sticking or something to do with the port or pickit?

*** SOLVED (below) ***

Thanks!
 
Last edited:

Thread Starter

blah2222

Joined May 3, 2010
582
Weird, I also tried making an binary up-counter for my 8 LEDs and instead of counting to 255 (0xFF), it only counts to 63 (0x3F)... What the heck?

My code is as follows:

Rich (BB code):
/** CONFIGURATION BITS**/

#pragma config FOSC = INTIO67, FCMEN = OFF, IESO = OFF                       // CONFIG1H
#pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 30                        // CONFIG2L
#pragma config WDTEN = OFF, WDTPS = 32768                                     // CONFIG2H
#pragma config MCLRE = OFF, LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC       // CONFIG3H
#pragma config STVREN = ON, LVP = OFF, XINST = OFF                          // CONFIG4L
#pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF                   // CONFIG5L
#pragma config CPB = OFF, CPD = OFF                                         // CONFIG5H
#pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF               // CONFIG6L
#pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF                           // CONFIG6H
#pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF           // CONFIG7L
#pragma config EBTRB = OFF           

/** INCLUDES **/

#include "p18f46k20.h"
#include "delays.h"

/** VARIABLES **/

#pragma udata
unsigned char LED_Number; //8-bits

/** DECLARATIONS **/

#pragma code

void main (void)
{
   LED_Number = 0x00;
   TRISD = 0x00; //all bits are outputs for LEDs

   while (1)
   {
      LATD = LED_Number;
      LED_Number++;

      if (LED_Number == 0xFF)
         LED_Number = 0x00;
   }
}
Can anyone see why this is only counting to 63 not 255?

I would like to debug this line by line with my PICKIT3 but I keep getting this error:

"PK3Err0040: The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding."

Continued trial of getting the debugger to work. I can debug Lesson 1: Hello LED without any errors, but when I try to debug either Lesson 2: Blink LED or Lesson 3: Rotate LED, I get the recurring PK3Err0040. Hmm... It makes me feel like this has something to do with the configuration bits for the internal oscillator or another configuration bit.

*** SOLVED DEBUGGING AND LED PROBLEMS ***

For some reason Lesson 1 could debug on 3.250 V, but Lessons 2 and 3 needed the PICKIT3 to provide 3.500 V... Weird and this also solved the problem I had (above) about the LED7 not lighting up. I guess there needed to be more power driven into the kit for all those LEDs to be lit.

I hope this helps someone who was in the same situation as I was...
 
Last edited:
Top