Sequence of statements makes code work differently. (PIC16F628A)


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124

    Default Sequence of statements makes code work differently. (PIC16F628A)

    Hello,

    below is the super simple code

    Code:
    SIKO:
    HIGH PORTA.0
    HIGH PORTA.1
    PAUSE 500
    LOW PORTA.0
    LOW PORTA.1
    PAUSE 500
    GOTO SIKO
    There are leds connected to porta.1 and porta.0

    The above code works, but only first line

    If I place at first line code for PORTA.0 it works, but next line, for PORTA.1 does not works. If I swap them, then PORTA.1 will work, but PORTA.0 - not. But if I modify code a bit, to look like this, then it works properly.

    SIKO:
    HIGH PORTA.0
    PAUSE 500
    LOW PORTA.0
    HIGH PORTA.1
    PAUSE 500
    LOW PORTA.1
    GOTO SIKO

    [/code]


    Why this happens?

    I have no TRISA, etc defined, as manual told us, HIGH/LOW statement in PBP does all necessary, so this is why it is so slow, but it appears not to work?

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default Re: Sequence of statements makes code work differently. (PIC16F628A)

    Without seeing your schematic, my guess would be the Read-Modify-Write issue documented in the data sheet. Try to write to PORTA as a whole rather than in bits to confirm this is the issue.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Sequence of statements makes code work differently. (PIC16F628A)

    Resistor-led-pin, that's all

  4. #4
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Sequence of statements makes code work differently. (PIC16F628A)

    Strange, and how to write PORTA in whole? like this?

    PORTA=%00000001

    ?

  5. #5
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Sequence of statements makes code work differently. (PIC16F628A)

    It does not work, even setting PORTA.1=1 does nothing

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: Sequence of statements makes code work differently. (PIC16F628A)

    Try

    Code:
    SIKO:
    PORTA=%00000011
    PAUSE 500
    PORTA=%00000000
    PAUSE 500
    GOTO SIKO
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Sequence of statements makes code work differently. (PIC16F628A)

    Everybody together now:
    Remember to disable analog functions...
    Remember to disable analog functions...
    Remember to disable analog functions...

    /Henrik.

Similar Threads

  1. Darrels interrupts and multiple SOUND statements, will it work?
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 31
    Last Post: - 26th January 2015, 07:42
  2. Replies: 13
    Last Post: - 10th July 2012, 18:05
  3. LED chaser - Scanner Sequence PIC16F628A
    By izzyblackout in forum Code Examples
    Replies: 4
    Last Post: - 3rd February 2011, 14:09
  4. Why doesn't this servo code work?
    By artswan in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th December 2009, 22:18
  5. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31

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