Page 1 of 1

PIC 16F690 with programming (need some advise to rebuild)

PostPosted: Wed Dec 12, 2012 4:31 pm
by wanes
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...

Re: PIC 16F690 with programming (need some advise to rebuild

PostPosted: Wed Dec 12, 2012 6:34 pm
by zhenning
whats the error?

Re: PIC 16F690 with programming (need some advise to rebuild

PostPosted: Mon Dec 17, 2012 8:15 pm
by shahrul
Not many use Assembly Language nowadays.

Re: PIC 16F690 with programming (need some advise to rebuild

PostPosted: Mon Dec 17, 2012 8:55 pm
by ABSF
Here's the corrected program code.....

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 <P16f690.inc>
   __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)


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


   cblock 0x20
CounterA                 ; these variables are all used as counters
CounterB                 ; in the delay subroutine
CounterC
   endc


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

   ORG 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


Allen