Electronics Quick PIC questions

Discussion in 'Modding' started by ch424, 28 Jun 2005.

  1. ch424

    ch424 Design Warrior

    Joined:
    26 May 2004
    Posts:
    3,112
    Likes Received:
    41
    Hi,
    I couldn't find this on google, so two quick questions:

    1. If you have 0x00 in a reg, then do
    decf reg,f
    (therefore reg = 0xFF) does the carry flag get set?

    2. If you have 0x00 in the working register and 0x00 in a reg, then you do
    subwf reg,f
    will the carry flag get set?

    I'm getting otherwise inexplicable behaviour from the MPLAB simulator and a 16F84.

    Thanks for any help

    ch424
     
  2. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    1. No
    2. Yes
     
  3. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    all in the data sheets.
     
  4. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    Indeed. If you're getting "inexplicable behaviour" you've mis-read or not read something ;)
     
  5. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    i wouldn't go that far, the sim does have some limitations (thou most seam documented... now) but its often someone does something silly (like let MCLR float) and can't figure out why their code isn't behaving properly.

    The art of PIC programming is reading the datasheets. Multipule monitors kick arse for this! (or a laptop or something to read the datasheets (product line + device datasheet).
     
  6. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    Yeah, but he said the sim AND his PIC... :)

    A laser printer is also useful for those datasheets :)
     
  7. ConKbot of Doom

    ConKbot of Doom Minimodder

    Joined:
    2 Jul 2003
    Posts:
    2,160
    Likes Received:
    6

    I wouldnt try one for the Mid-Range MCU Family Reference manual though :p

    Maybe sections, but not the whole thing.
     
  8. ch424

    ch424 Design Warrior

    Joined:
    26 May 2004
    Posts:
    3,112
    Likes Received:
    41
    Ah, great thanks - I hadn't thought of checking the actual datasheet! QUOTE: "2: Yes" explains why I'm getting these problems! I'll have to re-write that bit of the program then!

    thanks again

    ch424
     
  9. ch424

    ch424 Design Warrior

    Joined:
    26 May 2004
    Posts:
    3,112
    Likes Received:
    41
  10. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    It's just due to the way you subtract 2's compliment numbers.

    ConKbot.. I have the midrange manual, and 16 of the PIC datasheets for 10F, 12F, 16F and 18F series printed out. :p:)
     
  11. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
  12. ConKbot of Doom

    ConKbot of Doom Minimodder

    Joined:
    2 Jul 2003
    Posts:
    2,160
    Likes Received:
    6

    Thats what I should have done while still in school... :duh:
     
  13. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    multipule monitors kick arse!
     

Share This Page