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

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

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

Postby wanes » Wed Dec 12, 2012 4:31 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 with programming (need some advise to rebuild

Postby zhenning » Wed Dec 12, 2012 6:34 pm

whats the error?
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

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

Postby shahrul » Mon Dec 17, 2012 8:15 pm

Not many use Assembly Language nowadays.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

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

Postby ABSF » Mon Dec 17, 2012 8:55 pm

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
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 1 guest