PICKIT3 Debug Express Question

Discussion in 'Embedded Systems and Microcontrollers' started by blah2222, Jun 30, 2011.

  1. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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: Jul 4, 2011
  2. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    Are linker files even necessary anymore?
     
  3. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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.)
     
    blah2222 likes this.
  4. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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:
     
  5. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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
     
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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: Jul 1, 2011
    blah2222 likes this.
  7. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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: Jul 2, 2011
  8. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    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
     
  10. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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!
     
  11. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    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
     
  12. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    lol ok, so what do you think about the 16F84A?
     
  13. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    blah2222 likes this.
  14. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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:

    Code ( (Unknown Language)):
    1.  
    2. #pragma code
    3.  
    4. void main (void)
    5. {
    6.    TRISD = 0x00; //all bits are outputs
    7.    LATD = 0xFF; //all bits are high (all LEDs on)
    8.  
    9.    while (1)
    10.    {
    11.       ;
    12.    }
    13. }
    14.  
    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: Jul 4, 2011
  15. blah2222

    Thread Starter Well-Known Member

    May 3, 2010
    554
    33
    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:

    Code ( (Unknown Language)):
    1.  
    2.  
    3. /** CONFIGURATION BITS**/
    4.  
    5. #pragma config FOSC = INTIO67, FCMEN = OFF, IESO = OFF                       // CONFIG1H
    6. #pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 30                        // CONFIG2L
    7. #pragma config WDTEN = OFF, WDTPS = 32768                                     // CONFIG2H
    8. #pragma config MCLRE = OFF, LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC       // CONFIG3H
    9. #pragma config STVREN = ON, LVP = OFF, XINST = OFF                          // CONFIG4L
    10. #pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF                   // CONFIG5L
    11. #pragma config CPB = OFF, CPD = OFF                                         // CONFIG5H
    12. #pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF               // CONFIG6L
    13. #pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF                           // CONFIG6H
    14. #pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF           // CONFIG7L
    15. #pragma config EBTRB = OFF          
    16.  
    17. /** INCLUDES **/
    18.  
    19. #include "p18f46k20.h"
    20. #include "delays.h"
    21.  
    22. /** VARIABLES **/
    23.  
    24. #pragma udata
    25. unsigned char LED_Number; //8-bits
    26.  
    27. /** DECLARATIONS **/
    28.  
    29. #pragma code
    30.  
    31. void main (void)
    32. {
    33.    LED_Number = 0x00;
    34.    TRISD = 0x00; //all bits are outputs for LEDs
    35.  
    36.    while (1)
    37.    {
    38.       LATD = LED_Number;
    39.       LED_Number++;
    40.  
    41.       if (LED_Number == 0xFF)
    42.          LED_Number = 0x00;
    43.    }
    44. }
    45.  
    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: Jul 4, 2011
Loading...