1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Need help - need to flash a LED on PortA

Discussion in 'Embedded' started by zalzon, Dec 19, 2003.

  1. zalzon

    zalzon Guest

    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
     
    zalzon, Dec 19, 2003
    #1
    1. Advertisements

  2. 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.

    Best regards,
    Spehro Pefhany
     
    Spehro Pefhany, Dec 19, 2003
    #2
    1. Advertisements

  3. zalzon

    CBarn24050 Guest

    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.
     
    CBarn24050, Dec 20, 2003
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.