1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

pic programming.................. what next?

Discussion in 'Microcontrollers' started by tama182, Jan 4, 2006.

  1. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    yeh thanks atferrari, i did that last night, and it did make it much clearer, but can anyone answer my previous post

     
  2. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,323
    Likes:
    653
    Location:
    Derbyshire, UK
    No idea, and why does it matter? (unless you're a chip designer at MicroChip), a GOTO takes two instruction cycles, and is clearly specified as such in the datasheet.
     
  3. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    ONLINE
    You should download and read the 16F628 datasheet from Microchip. Section 15 describes what all the instructions do and explains that any instruction that changes PCL will take 2 cycles. So call, return, goto, btfss and a few others do/can take 2 cycles - the btfss type only take 2 if they skip.

    Mike.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. tkbits

    tkbits Member

    Joined:
    Aug 21, 2005
    Messages:
    89
    Likes:
    0
    Location:
    US

    The full datasheet explains why GOTO will always take two cycles.

    Yes, it is the flushing of a prefetched instruction.
     
  6. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    ok ok ok.............why you given me such a hard time, all these replys you give me are aimed towards more than a noob,

    im trying to understand your tutorials, and i want to understand how every line works, and at no point does it explain that a goto takes two instructions !!!!

    thanks for telling me to look in the pdf and i will, but whats with all the bitchyness LOL 8) , :wink: ,

    gimme a break !!
     
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,323
    Likes:
    653
    Location:
    Derbyshire, UK
    As you can perhaps imagine?, we get LOT'S of questions, a great many simply because the poster hasn't bothered to read the datasheet. This should ALWAYS be the first thing you do.
     
  8. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    when using mplab 7.3, is it possible to view the program counter, like you would watch all the regisiters etc under the watch tool, i can see PCL, but not PC
     
  9. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    Nigel, i am following your guide aswell as my book, but the pic i got was a 628a rather than a 628, is there anything i should watch out for?
     
  10. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,323
    Likes:
    653
    Location:
    Derbyshire, UK
    Basically just to check the config fuse settings, have a look at the migration document at MicroChip at http://www.electro-tech-online.com/custompdfs/2006/01/40048a.pdf.
     
  11. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    ONLINE
    If your using MPLAB SIM then the PC is at the bottom of the screen.

    Mike.
     
  12. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    OK, WHY DO I ALWAYS GET PROBLEMS !!!!!

    well as you know, Nigels tutorials are written for the 628, im using a 628a which ive checked will program and debug on my icd2,

    im on tutorial 1.6 at the moment, the bouncing LED, when i program it, it works fine, but for some reason im not able to debug it,

    i quickbuild first,

    then when going to debug mode i get

    so anyway i click ok and then program, where i get this in the output box





    so then i try to run it and i get

    so i click ok, then i get this in the output box


    i dont get it, ive made sure that the device is set to 628A in both the code and the select device.... tab

    but even though it does program and work, i do get this

    but even though i click ok it still works,

    any ideas why this would be happening?
     
  13. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
  14. 2camjohn

    2camjohn New Member

    Joined:
    Mar 12, 2004
    Messages:
    313
    Likes:
    0
    Location:
    South Manchester
    I dont know if this helps but often my simulator finds errors in my code that works perfectly fine on the chip.
    Usually it is to do with conflicting setup code.



    Also dont have a go at Nigel, many people of his expertees dont waste their time helping newbies.
    If you post a question about something relatively complex, then expect a complex answer.
     
  15. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    well its just that all of the tutorials wont debugg, i think it has somthing to do with the configuration mode that is being used, i mean the 628 doesn't debugg with the icd2, just the 628a, and i have made sure to change that at the beginning of the code,

    all the tutorials have __config 0x3D18

    and i think that the debugg wont work with it, is there anyone who knows if i am right?

    to be honest i dont even know where that number comes from because the pic 16f628.inc has this

    _BODEN_ON EQU H'3FFF'
    _BODEN_OFF EQU H'3FBF'
    _CP_ALL EQU H'03FF'
    _CP_75 EQU H'17FF'
    _CP_50 EQU H'2BFF'
    _CP_OFF EQU H'3FFF'
    _DATA_CP_ON EQU H'3EFF'
    _DATA_CP_OFF EQU H'3FFF'
    _PWRTE_OFF EQU H'3FFF'
    _PWRTE_ON EQU H'3FF7'
    _WDT_ON EQU H'3FFF'
    _WDT_OFF EQU H'3FFB'
    _LVP_ON EQU H'3FFF'
    _LVP_OFF EQU H'3F7F'
    _MCLRE_ON EQU H'3FFF'
    _MCLRE_OFF EQU H'3FDF'
    _ER_OSC_CLKOUT EQU H'3FFF'
    _ER_OSC_NOCLKOUT EQU H'3FFE'
    _INTRC_OSC_CLKOUT EQU H'3FFD'
    _INTRC_OSC_NOCLKOUT EQU H'3FFC'
    _EXTCLK_OSC EQU H'3FEF'
    _LP_OSC EQU H'3FEC'
    _XT_OSC EQU H'3FED'
    _HS_OSC EQU H'3FEE'


    anyonw want to explain where __config 0x3D18
    comes from please :lol:
     
  16. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,323
    Likes:
    653
    Location:
    Derbyshire, UK
    The value 0x3D18 is for the config word in the 16F628 for the options required for my tutorials - you can 'AND' the equates above to generate a similar value. However, I suggest comparing the 628 and 628A datasheets to see what you actually need, as there are differences in the config word between the two.
     
  17. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    do you think that the configuration type could be the problem why i cant get your tutorials to debug
     
  18. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,323
    Likes:
    653
    Location:
    Derbyshire, UK
    Quite possibly?, check the 628A datasheet and set the config word accordingly.

    However, there's no 'debug' setting in the config word (as there is in some PIC's) - but the config still needs altering for the 628A.
     
  19. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    what do you mean set it accordingly, remember im a noob i have no idea what all the different configurations do, im still learning the code,
     
  20. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,323
    Likes:
    653
    Location:
    Derbyshire, UK
    Use 0x2118 for the config word, that's the same settings as for the 628, don't know if it will help debugging?, like I said there's no options for that.
     
  21. tama182

    tama182 New Member

    Joined:
    Jan 4, 2006
    Messages:
    57
    Likes:
    0
    turns out that a header interface board is required,.........damn :evil:
     

Share This Page