PIC 16F690

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

PIC 16F690

Postby wanes » Wed Dec 12, 2012 4:29 pm

flexi-drive.asm
CODE: SELECT_ALL_CODE
; sample code in Microchip Technology PIC Assembly Language
; to accompany a circuit that controls Flexinol actuator wire
;
; individual pins RC0-RC3 are brought high for intervals of approximately
; one second and the cycle repeats endlessly
;---------------------------------------------------------------------------------

;---------------------------------------------------------------------------------
;  initialization - load the standard include file and set the configuration bits
;---------------------------------------------------------------------------------


list p=16F690                             
#include
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF
                & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)


;---------------------------------------------------------------------------------
;  variables
;---------------------------------------------------------------------------------


UDATA
  CounterA res 1                ; these variables are all used as counters
  CounterB res 1                ; in the delay subroutine
  CounterC res 1



;---------------------------------------------------------------------------------
;  Code
;---------------------------------------------------------------------------------

CODE 0x00

Start:
   banksel   TRISC
   clrf      TRISC               ; make PORTC all output
   banksel   PORTC

PinCycle:
   movlw     b'00000001'         ; put the bit pattern for the outputs into W
   movwf     PORTC               ; load the bit pattern into PORTC
   call      OneSecondDelay      ; go to the delay subroutine
   movlw     b'00000010'         ; repeat for the next pattern...
   movwf     PORTC               
   call      OneSecondDelay
   movlw     b'00000100'
   movwf     PORTC               
   call      OneSecondDelay
   movlw     b'00001000'
   movwf     PORTC               
   call      OneSecondDelay
   goto      PinCycle


OneSecondDelay:                  ; the delay routine is based on a sequence
   movlw     0x06                ; of nested loops which have been calculated to
   movwf     CounterC            ; take approximately one second to complete
   movlw     0x18
   movwf     CounterB
   movlw     0xA7
   movwf     CounterA
OSDLoop:
   decfsz    CounterA,1
   goto      OSDLoop
   decfsz    CounterB,1
   goto      OSDLoop
   decfsz    CounterC,1
   goto      OSDLoop
   return

end


this is the coding for the PIC 16F690 to control shape memory alloy. but this coding has missing some thing and error when i try to compiled. Some one can help me to solve this problem...
wanes
Freshie
 
Posts: 4
Joined: Fri Nov 02, 2012 10:22 am

Re: PIC 16F690

Postby yonghui » Thu Dec 13, 2012 3:41 pm

i dont write asm code for PIC. sorry cant help u.
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: PIC 16F690

Postby zhenning » Thu Dec 13, 2012 5:55 pm

;flexi-drive.asm
;
; sample code in Microchip Technology PIC Assembly Language
; to accompany a circuit that controls Flexinol actuator wire
;
; individual pins RC0-RC3 are brought high for intervals of approximately
; one second and the cycle repeats endlessly
;---------------------------------------------------------------------------------

;---------------------------------------------------------------------------------
; initialization - load the standard include file and set the configuration bits
;---------------------------------------------------------------------------------


list p=16F690
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF
& _BOR_OFF & _IESO_OFF & _FCMEN_OFF)


;---------------------------------------------------------------------------------
; variables
;---------------------------------------------------------------------------------


UDATA
CounterA res 1 ; these variables are all used as counters
CounterB res 1 ; in the delay subroutine
CounterC res 1



;---------------------------------------------------------------------------------
; Code
;---------------------------------------------------------------------------------

CODE 0x00

Start:
banksel TRISC
clrf TRISC ; make PORTC all output
banksel PORTC

PinCycle:
movlw b'00000001' ; put the bit pattern for the outputs into W
movwf PORTC ; load the bit pattern into PORTC
call OneSecondDelay ; go to the delay subroutine
movlw b'00000010' ; repeat for the next pattern...
movwf PORTC
call OneSecondDelay
movlw b'00000100'
movwf PORTC
call OneSecondDelay
movlw b'00001000'
movwf PORTC
call OneSecondDelay
goto PinCycle


OneSecondDelay: ; the delay routine is based on a sequence
movlw 0x06 ; of nested loops which have been calculated to
movwf CounterC ; take approximately one second to complete
movlw 0x18
movwf CounterB
movlw 0xA7
movwf CounterA
OSDLoop:
decfsz CounterA,1
goto OSDLoop
decfsz CounterB,1
goto OSDLoop
decfsz CounterC,1
goto OSDLoop
return

end
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest

cron