1. nadia23

    Thread Starter New Member

    Sep 29, 2013
    25
    0
    Sorry I am very new with Assembly and I am using PicKit2 and I can't figure out how to blink all LEDs, I can only Turn on one LED this is my code so for

    Code ( (Unknown Language)):
    1.  
    2. #include <p16F690.inc>
    3. __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF)
    4.  
    5.  
    6. ORG 0x00
    7.  call setLEDs ; Setup LED outputs
    8.  bsf PORTC,0 ; Turn LED 0 on
    9.  goto $ ; Wait here
    10.  
    11. ; Subroutine to setup LED output port on PIC development board
    12. setLEDs
    13.  BANKSEL TRISC ; Select bank 1
    14.  clrf TRISC ; Set PORTC to outputs
    15.  BANKSEL PORTC ; Select bank 0
    16.  
    17.  return
    18.  
    19.  END
    20.  
     
    Last edited by a moderator: Oct 24, 2013
  2. JDT

    Well-Known Member

    Feb 12, 2009
    658
    85
    You can, of course, send a byte to the port register to switch a number of pins simultaneously.

    Example:
    MOVLW B'00001101'
    MOVWF PORTA

    You can also read a port so if you want to toggle some pins without affecting others you can read, XOR and write back like this:-

    MOVF PORTA,W ;copy current state of PORTA into W
    XORLW B'00000110' ;Toggle bits 1 and 2
    MOVWF PORTA ;Write back to PORTA
     
    nadia23 likes this.
  3. nadia23

    Thread Starter New Member

    Sep 29, 2013
    25
    0
    thanks a lot for your reply, but sorry I am not sure where exactly I should do these changes that you suggested me; should I edit the setLED subroutine with moving the bits 1 and 2?.
     
    Last edited: Oct 24, 2013
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    You should place them at the point in your program where you wish the LED to change.
     
    nadia23 likes this.
  5. nickelflipper

    Active Member

    Jun 2, 2010
    280
    35
    To initialize ports take a look at the I/O PORTS chapter of the data sheet. To initialize all ports digital "clrf" PORTA, PORTC, ANSEL, and ANSELH.
     
    nadia23 likes this.
  6. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    nadia23 likes this.
Loading...