Newbie help. PIC18F45k20 pickit debug express


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Hi, welcome to the forum!

    There are several thing "going on" here. First of all it would be nice to know what version of PBP you're using - I'm going to assume (since you're using the now reserved word Loop as a label) that it's not the latest PBP3 but some earlier version.

    OK, as far as I can see the C-code you posted is setup to use the internal oscillator of the 46K20 device (I suspect this is how the debug express board is layed out) but the default setting when compiling for the 46K20 with PBP is to use an external x-tal and I suspect this is the main reason for it not to work.

    The way to rectify this problem depends on the version of PBP you're using and the following holds true for version prior to PBP3.

    In your PBP inatallation folder, look for and open the file named 18F45K20.INC (make sure you open the correct file), in it you'll find the following:
    Code:
            NOLIST
        ifdef PM_USED
            LIST
            "Error: PM does not support this device.  Use MPASM."
            NOLIST
        else
            LIST
            LIST p = 18F45K20, r = dec, w = -311, w = -230, f = inhx32
            INCLUDE "P18F45K20.INC" ; MPASM  Header
            __CONFIG    _CONFIG1H, _FOSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
            __CONFIG    _CONFIG2H, _WDTEN_ON_2H & _WDTPS_512_2H
            __CONFIG    _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _HFOFST_ON_3H & _MCLRE_ON_3H
            __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
            NOLIST
        endif
            LIST
    EEPROM_START EQU 0F00000h
    BLOCK_SIZE EQU 32
    See that first __CONFIG _CONFIG1H, _FOSC_HS_1H..... that I highlighted? That is what is telling the PIC to run with an external x-tal, which I don't think you have on that board. Try changing from _FOSC_HS_1H to _FOSC_INTIO67_1H - make sure you backup the file before making changes to it! The line should look like:
    Code:
            __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _FCMEN_OFF_1H & _IESO_OFF_1H


    Next, there's no need to make aliases to register names in the context you've done (with the SYMBOL "command"), all the register names and their respective adresses are already defined for you in header-files for all the PICs that the compiler supports and they get included automatically when you compile for a particular device (the one you select in the dropdown list within Micro Code Studio in this case).

    Also, Peek and Poke is not needed or even recomended with PBP, you can write directly to the registers referring to them by their name, like:
    Code:
     
    TRISD.0 = 0   ' Make PortD.0 an output
     
    Main:
      PortD.0 = 1
      Pause 500
      PortD.0 = 0
      Pause 500
    Goto Main
    /Henrik.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Thanks mister_e,

    This looks like something I can do. I'll look into this. Do you know if it will work for PICkit3 as well?
    I am microcontroller stupid!!

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Hi,
    Im using the free demo version of PBP right for now.
    OK, it doesn't say much to me I'm afraid... Is it a demo version of 2.4, 2.5, 2.6, 3.0 or what? As long as it's not 3.0 editing the .inc file like I showed should work. In 3.0 Melabs have provided us with a better way to handle the CONFIG bits but lets not get into that if you're not using 3.0.

    Im a little vague on understaning what exactly is a INC file. It seems like the books I have read don't go into detail on this very much for the beginner. What I am gathering is that its a file that is attached to the source program when the program is compiled.
    Yes, that is correct. For each device there's .INC file in the PBP folder, the file for the device you select in the drop-down list in Micro Code Studio gets included in your source file before the actual compilation process starts.

    What happens is that MicroCodeStudio passes the name of the device to the compiler thru its -P parameter (see the manual for details on that) and the compiler then "adds" the content of the .INC file to your source file before compiling.

    This tells the compiler which ports to use and how to setup the ports?
    Pretty much, it doesn't say how to set them up (ie. inputs, outputs, analog, digital etc) but it tells the compiler at which physical adress in memory that each register is (PORTA, TRISA, TMR0, T0CON, ANSEL, RCON, whatever). Pretty much like you did with the SYMBOL statements but it does it for you for ALL the regsiters in the chip so you don't have to dig that deep in the datasheet. Small chips might have a dozen or so register, large chips have hundreds of registers.

    Actually, if you look in the 18F45K20.INC file in the PBP folder you'll see there's another include statement in this file, namely INLCUDE P18F45K20.INC which is located in the MPASM directory. It's in this file that the actual names of the registers and their adresses are located.

    In practice it means that you don't have to know the physical adress of the register you want to access, you just need to know its name. The rest is handled for you behind the scenes. So, except for editing the CONFIG bits you rarely need to worry about these files.

    /Henrik.

  5. #5
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Ahhh, this clears up some confusion. Now I think I fiqured out why I could never understand MPLAB---adding INC and HEADER files. All the beginner tutorials show you how to get your first "Hello World" up and going but doesn't really explain how it all works and why your doing the things your doing. Like:

    Open this file, click here, click here, look at datasheet, click here, now click compile then program....viola, your first program yaa!!!!!

    It left me scratching my head wondering if I needed to add any INC files to my own program? If so then which one? Theres tons of them.. uhmm.... OWNPRG.INC J/K

    Thanks your help. I'll give these suggestions a go and see how it all turns out.

    Thanks again
    I am microcontroller stupid!!

  6. #6
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Quote Originally Posted by HenrikOlsson View Post
    Hi,

    Is it a demo version of 2.4, 2.5, 2.6, 3.0 or what? As long as it's not 3.0 editing the .inc file like I showed should work. In 3.0 Melabs have provided us with a better way to handle the CONFIG bits but lets not get into that if you're not using 3.0.

    /Henrik.
    Im using PBP3.0 the latest release.

    I still ween into the INC file for PIC18f45k20 and made the changes like you stated, however it still didn't work. I tryed some other PBP example codes that came with the installation files and those didn't work either so I feel like theres something else in the INC file that needs to be changed because as I said before, all the hex example codes that are for the pic18f45k20 debug kit work fine. Only the PBP example ones don't. I scanned over the datasheet last night to try and see if there was any other config bits that looked like they might need to be changed but alot of them are over my head right now and I don't really understand them. Got any other suggestions?

    Thanks
    I am microcontroller stupid!!

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    with PBP3 you no longer need to edit the .INC files. you need to use the new method stated in the migration document.(#CONFIG, #ENDCONFIG)

    http://www.pbp3.com/downloads/Migrat...0to%20PBP3.pdf
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Quote Originally Posted by mister_e View Post
    with PBP3 you no longer need to edit the .INC files. you need to use the new method stated in the migration document.(#CONFIG, #ENDCONFIG)

    What is the configuration block. Is that a insert of the program code?

    For example

    ;***************header

    #CONFIG
    __config _XT_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
    #ENDCONFIG

    Main:

    bla bla bla bla bla

    Goto Main
    End

    ????
    I am microcontroller stupid!!

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Quote Originally Posted by redmobiusv View Post
    Thanks mister_e,

    This looks like something I can do. I'll look into this. Do you know if it will work for PICkit3 as well?
    It should be really close. I don't have PICKIT 3 myself, maybe It's time for me to grab one of those translucent red box just to sit aside the other dust-gathering device i have on my shelf and bench
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Aug 2011
    Posts
    12


    Did you find this post helpful? Yes | No

    Default Re: Newbie help. PIC18F45k20 pickit debug express

    Henrik, Thanks replying.

    Quote Originally Posted by HenrikOlsson View Post
    First of all it would be nice to know what version of PBP you're using
    Im using the free demo version of PBP right for now.

    Tonight I will make the changes to the INC file like you suggested an see if that fixes it.

    I have some questions though. Forgive me if they sound beginner-ish..

    Im a little vague on understaning what exactly is a INC file. It seems like the books I have read don't go into detail on this very much for the beginner. What I am gathering is that its a file that is attached to the source program when the program is compiled. This tells the compiler which ports to use and how to setup the ports? Is that what your saying when you said?:

    Quote Originally Posted by HenrikOlsson View Post
    Next, there's no need to make aliases to register names in the context you've done (with the SYMBOL "command"), all the register names and their respective adresses are already defined for you in header-files for all the PICs that the compiler supports and they get included automatically when you compile for a particular device (the one you select in the dropdown list within Micro Code Studio in this case).
    Last edited by redmobiusv; - 8th August 2011 at 19:43.
    I am microcontroller stupid!!

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts