Need help - need to flash a LED on PortA

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi,
    this is driving me insane.  I am unable to figure out why my code
(below) to blink a LED on PortA does not work.  The test circuit is
fine.  Everything compiles and burns onto the 628A PIC chip.  But it
does not do jack.  

Could someone please help me out here.

Thank you,
zalzon

------
;portsend.asm to show to flash a led on porta, ra0.

;************************************* setup

list p = 16F628A ;processor type
org 0020h

STATUS equ h'3'
CMCON equ h'1F'
TRISA equ h'85'
RP1 equ h'6'
RP0 equ h'5'
PORTA equ h'05'
reg1 equ h'20'

;************************************* program

goto Start

Start
 MOVLW 0x07    ;disable the comparators
 MOVWF CMCON

 bsf STATUS, RP0  ;switch to bank 1
 bcf STATUS, RP1

 movlw b'00000000'   ;all IO pins = outputs
 movwf TRISA

 bcf STATUS, RP0   ;switch back to bank 0
 bcf STATUS, RP1

 movlw b'00000000'       ; all port pins = low
 movwf PORTA
      
 goto Test


Test
 movlw d'255'     ;counter to delay for a few milliseconds
 movwf reg1
 
 BSF PORTA,0    ;set porta, bit 0 on
 goto Decrement1     ;begin delay
Back1
 BCF PORTA,0     ;set porta, bit 0 off
 movlw d'255'
 movwf reg1
 goto Decrement2
Back2
 goto Test


Decrement1
 nop
 nop
 nop
 decfsz reg1, 1
 goto Decrement1
 goto Back1

Decrement2
 nop
 nop
 nop
 decfsz reg1, 1
 goto Decrement2
 goto Back2

Finished
 end

Re: Need help - need to flash a LED on PortA
On Fri, 19 Dec 2003 22:18:46 GMT, the renowned zalzon

Quoted text here. Click to load it

You need to set an org for the code memory. Try using CBLOCK
rather than org for the file registers, if you want to write your
program in absolute.


Quoted text here. Click to load it

Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
snipped-for-privacy@interlog.com             Info for manufacturers: http://www.trexon.com
We've slightly trimmed the long signature. Click to see the full one.
Re: Need help - need to flash a LED on PortA
Hi, pic code starts at org0 not 20. You can find some templates on the
microchip site. Some chips have adconverters on porta, they come up as analoge
from reset.

Site Timeline