portA problem


Closed Thread
Results 1 to 17 of 17

Thread: portA problem

Hybrid View

  1. #1

    Default portA problem

    Hi!

    I do not know what is going on!

    PortB works just fine,
    but
    a) code does NOT toggle the test (test1, test2) pins
    b) code does toggle the test pins

    test1 = portA.1 and test2 = portA.2

    'a)
    loop:
    pause 5
    toggle test1
    toggle test2

    if portB = 0 then
    portB = $ff
    '// toggle test1
    else
    portB = 0
    '// toggle test2
    endif
    goto loop:

    'b)
    loop:
    pause 5
    '// toggle test1
    '// toggle test2

    if portB = 0 then
    portB = $ff
    toggle test1
    else
    portB = 0
    toggle test2
    endif
    goto loop:


    Could somebody please try to explain how this is possible?
    I'm puzzled, how is this possible?
    Using picbasicpro 2.50

    regards
    key

  2. #2
    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...

  3. #3


    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

  4. #4
    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...

  5. #5


    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

  6. #6
    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...

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