LED Help

Thread Starter

nadia23

Joined Sep 29, 2013
25
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

Rich (BB code):
#include <p16F690.inc> 
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _IESO_OFF & _FCMEN_OFF) 


ORG 0x00
 call setLEDs ; Setup LED outputs
 bsf PORTC,0 ; Turn LED 0 on
 goto $ ; Wait here
 
; Subroutine to setup LED output port on PIC development board
setLEDs 
 BANKSEL TRISC ; Select bank 1
 clrf TRISC ; Set PORTC to outputs
 BANKSEL PORTC ; Select bank 0

 return
 
 END
 
Last edited by a moderator:

JDT

Joined Feb 12, 2009
657
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
 

Thread Starter

nadia23

Joined Sep 29, 2013
25
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:

ErnieM

Joined Apr 24, 2011
8,377
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?.
You should place them at the point in your program where you wish the LED to change.
 
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
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.
 
Top