PIC18F Bit clear problem

Discussion in 'Embedded Systems and Microcontrollers' started by Robin Mitchell, Jul 9, 2013.

  1. Robin Mitchell

    Thread Starter Well-Known Member

    Oct 25, 2009
    734
    200
    Hi everyone,

    Im currently programming a pic using assembly. Now for some reason the BCF instruction only seems to execute after a specific delay. For example:

    Code ( (Unknown Language)):
    1.  
    2. LOOP    BSF     PORTA,0
    3.         BCF     PORTA,0
    4.         GOTO    LOOP
    5.  
    This does not appear to work at all! If however I write to the port directly (such as movlw 0x01 and then mowf porta) it works fine. What is going on???
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Search for "read, modify, write".
    Can't you use LATA on PIC18?
     
    Robin Mitchell and THE_RB like this.
  3. Robin Mitchell

    Thread Starter Well-Known Member

    Oct 25, 2009
    734
    200
    I can use LAT on pic18.
    What an interesting bug in the PICs, read modify write.....how funny :p
     
  4. atferrari

    AAC Fanatic!

    Jan 6, 2004
    2,651
    766
    Hola MITCH, the setting/resetting of bits in the respective LATch is explained as the solution of that problem, somewhere in their manuals for the 18F.

    Every time, identify TRIS to change IO direction / PORT to read input / LAT to write output. After that you can FORGET the RMW problem.

    You were lucky: given the right conditions you could have had changes in the port. :eek: Much worst.
     
Loading...