portA problem


Closed Thread
Results 1 to 17 of 17

Thread: portA problem

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by keymuu View Post
    I do not know what is going on!
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    And it would REALLY help to know which PIC you are using...

  2. #2


    Did you find this post helpful? Yes | No

    Default portA or TOGGLE problem?

    Quote Originally Posted by skimask View Post
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    And it would REALLY help to know which PIC you are using...
    Thanks for the reply...

    The prosessor is 18F4550

    and before the the code there is:
    trisA = 0
    trisB = 0

    So, actually i do not know if it is a portA problem or a TOGGLE failure?

    Regards
    Key

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Re-read that linked post above...read it good, read it carefully...then re-read the 3rd paragraph...then re-read it again...

    And if you're not sure if it's a TOGGLE failure or not, then don't use TOGGLE...
    Surely you can come up with a different method of changing the state of a bit from one to the other and back again...

  4. #4


    Did you find this post helpful? Yes | No

    Default toggle portA.1 problem

    Quote Originally Posted by skimask View Post
    Re-read that linked post above...read it good, read it carefully...then re-read the 3rd paragraph...then re-read it again...

    And if you're not sure if it's a TOGGLE failure or not, then don't use TOGGLE...
    Surely you can come up with a different method of changing the state of a bit from one to the other and back again...
    ...when I add ADCON1 = 7 to the code after trisA and trisB it does not change the outcome. Here is the code:

    DEFINE OSC 48
    '
    test1 var PORTA.1
    test2 var PORTA.2

    trisA = 0
    trisB = 0
    ADCON1 = 7

    ProgramStart:

    pause 5
    toggle test1 '// comment -- THIS DOES NOT WORK!
    toggle test2 '// these two lines AND

    if portB = 0 then
    portB = $ff
    '//toggle test1 '// uncomment -- THIS WORKS
    else
    portB = 0
    '//toggle test2 '// uncomment
    endif

    goto ProgramStart

    Depending where toggle is it either work or does not work. If you have the possibility to test this, please let me know if works on your pic.

    Thank you in advance

    Regards
    Key

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by keymuu View Post
    ...when I add ADCON1 = 7 to the code after trisA and trisB
    1/2 way there...keep reading and re-reading...
    And again...read the PBP manual about TOGGLE. Not that TOGGLE is a bad command, but there are other ways to flip a bit...

    Anybody got the link to the R-M-W 'writeup' thread here?
    The PIC is running 48Mhz here (apparently). I see possible R-M-W issues...

    Besides that...look at your code...There are logical flow flaws (is that the correct way to put that?) in it...
    How do you know TOGGLE isn't actually working the way it should?
    Can you see that fast? I can't...

  6. #6
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Default Is this the R-M-W thread?

    Quote Originally Posted by skimask View Post
    Anybody got the link to the R-M-W 'writeup' thread here?
    The PIC is running 48Mhz here (apparently). I see possible R-M-W issues...
    http://www.picbasic.co.uk/forum/showthread.php?p=34331
    Last edited by Pic_User; - 15th October 2008 at 00:16. Reason: Fix quote
    Ohm it's not just a good idea... it's the LAW !

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    That's one of them, but somewhere out there is a much longer, more involved explanation of the R-M-W issue. Someday I'll come across it again...

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    1/2 way there...keep reading and re-reading...
    And again...read the PBP manual about TOGGLE. Not that TOGGLE is a bad command, but there are other ways to flip a bit...

    Anybody got the link to the R-M-W 'writeup' thread here?
    The PIC is running 48Mhz here (apparently). I see possible R-M-W issues...

    Besides that...look at your code...There are logical flow flaws (is that the correct way to put that?) in it...
    How do you know TOGGLE isn't actually working the way it should?
    Can you see that fast? I can't...
    Thank you Skimask, you are right, I'm 1/2 way there and in fact even slightly further... I did read a little bit further also...

    Found in the pic18F4550 data sheet that LATA is about the same as PORTA, so I changed PORTA.1 to LATA.1 and that solved the issue. However I do not understand why PORTA does not work and LATA works in this "example". Could somebody try to explain that shortly, I am sure it will help ohter people also. Knowing that LATx is included in the 18F pics, but still does not grasp how it (change toggle place) works like it does?
    How could this be an r-m-w matter?

    Regards
    Key

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Read-Modify-Write, it's briefly explained in the PBP manual somewhere...and it's also explained in those links above a bit...

Similar Threads

  1. PIC16F877A analog problem
    By DeViLa_Q8 in forum mel PIC BASIC
    Replies: 0
    Last Post: - 30th July 2009, 20:19
  2. Problem with porta for 16F886(PIC 28X1)
    By Anghel Cosmin in forum Off Topic
    Replies: 2
    Last Post: - 26th February 2009, 13:07
  3. PIC's ports individual bits manipulation - how to?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 27th February 2007, 22:34
  4. Problem with ADC
    By savnik in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 25th November 2006, 07:37
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

Members who have read this thread : 0

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