Jump to content
Sign in to follow this  
ardyna

On Led Using Pic16f628a?

Recommended Posts

Hi! I'm new to asm and hopefully everyone here will guide me with my pic. I use PIC16F628A. I have searched a lot of asm examples and tried to do the simplest thing to my pic. I made an asm code to on an LED as below but the LED does not turn on :( I'm not sure what's wrong with my program. Can someone help?

 

LIST p=16F628a

#include <P16F628a.inc>

__Config _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _LVP_OFF & _MCLRE_OFF & _BODEN_OFF

 

 

cblock h'20'

 

endc

 

dly equ 0x30

LED equ 0xff

 

org 0x0000

start

goto initialize

 

initialize

movlw 0x07

movwf CMCON

 

bcf STATUS,RP1

bsf STATUS,RP0

 

clrf PIR1

 

clrf PORTA

clrf PORTB

 

movlw b'00000100' ; set RA2 = input dari switch others = output

movwf TRISA ; '1' for input and '0' for output

 

movlw 0x00 ; all output

movwf TRISB ;

 

main

call onIRLED

goto main

 

onIRLED

bsf PORTA,LED

call delay

bcf PORTA,LED

return

 

delay

movlw d'255'

movwf dly

D1 decfsz dly,f

goto D1

return

 

END

Share this post


Link to post
Share on other sites

Hi! I'm new to asm and hopefully everyone here will guide me with my pic. I use PIC16F628A. I have searched a lot of asm examples and tried to do the simplest thing to my pic. I made an asm code to on an LED as below but the LED does not turn on :lol: I'm not sure what's wrong with my program. Can someone help?

--------------------------

 

/quote]

 

I have tried to mod the program. the actual bit concerned- ididd not mind- it is working and the porta bits are changing. you may fine tune to what actually need.

Share this post


Link to post
Share on other sites
Hi! I'm new to asm and hopefully everyone here will guide me with my pic. I use PIC16F628A. I have searched a lot of asm examples and tried to do the simplest thing to my pic. I made an asm code to on an LED as below but the LED does not turn on :lol: I'm not sure what's wrong with my program. Can someone help?

 

 

please see this modded file . it is working and you may fine tune at bit level as per your requirements

 


  1. list p=16f628a
    #include <P16F628a.inc>
    __Config _CP_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _LVP_OFF & _MCLRE_OFF & _BODEN_OFF
    cblock h'20'
    endc
    dly equ 0x30
    LED equ 0x00
    org 0x0000
    start
    goto initialize
    initialize
    movlw 0x07
    movwf CMCON
    bcf STATUS,RP1
    bsf STATUS,RP0
    clrf PIR1
    clrf PORTA
    clrf PORTB
    bsf STATUS,RP0
    movlw 0x00 ; set RA2 = input dari switch others = output
    movwf TRISA ; '1' for input and '0' for output
    movlw 0x00 ; all output
    movwf TRISB ;
    main
    call ONIRLED
    goto main
    ONIRLED
    bsf STATUS,RP0
    movlw 0x00
    movwf TRISA
    bcf STATUS,RP0
    movlw 0xff
    movwf PORTA
    call delay
    movlw 0x00
    movwf PORTA
    call delay
    return
    delay
    movlw d'31'
    movwf dly
    D1 decfsz dly,f
    goto D1
    return
    END

Edited by Sarma

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×