pic16f88 assignment help

Thread Starter

bigbang42

Joined Nov 23, 2012
1
Right i have this code below which i need to use as an example to produce my own code i was hoping to do something like a temperature control system ie its too cold; raise temp. its too warm; lower temp. just something really basic but i'm struggling with it because honest to god my lecturer is terrible, to point he might even get the sack :|

please can anyone help me change this code even if its something other than temp control, i just need a basic pic16f88 application and code to go with.

Rich (BB code):
p=16f88 
          portb     equ 0x06 
          porta      equ 0x05 
          trisa      equ 0x85 
          trisb     equ 0x86 
          ansel      equ 0x9b 
          status      equ 0x03 

          count     equ 0x20 
          temp     equ 0x21 
          count2   equ 0x25 
          count22 equ 0x29 
          count25 equ 0x27 
          rotation equ 0x26 
          count3 equ  0x28 
                    org     0x0 
          goto     start 
          org     0x5 
start: 
                banksel     trisb 
          clrf     trisb 
          banksel     portb 
          clrf      portb 

          banksel ansel 
          movlw      0x00 
          movwf      ansel 
          banksel trisa 
          movlw      0x1f 
          movwf      trisa 
sensor1: 
          banksel porta 
checkbit0:      
          btfss      porta,0 
          goto      checkbit1 

 run:        call    stepper1 
             btfss   porta,0 
             goto    checkbit1 
             goto    run 
      
checkbit1:     bcf   portb,2 
             banksel porta 
check1:          btfss      porta,1 
              goto sensor3 

 run2:       call   stepper2 
             btfss  porta,1 
             goto  sensor3 
             goto   run2 
 sensor3: 
             bsf    portb,4 
          goto     sensor1 
stop:           goto stop 
stepper1: 
direction: 
          bsf portb,0 
loop1:      
pulseon: 
             bsf portb,2 
          nop 
pulsedown: 
          bcf  portb,2 
          nop 
pulsegap: 
          movlw     0xff 
          movwf     count2 
timeit3: 
              call    wait 
          decfsz     count2 
          goto     timeit3 
return 
stepper2: 
direction2: 
          bsf  portb,4 
loop2:      
pulseon2: 
             bsf portb,6 
          nop 
pulsedown2: 
          bcf portb,6 
          nop 
pulsegap2: 
          movlw     0xff 
          movwf     count25 
 timeit32: 
              call    wait 
          decfsz     count25 
          goto     timeit32 
          return 
; MAIN BLOCK DELAY: 

wait:      
          movlw     0x01 
          movwf   count 
 timeit: 
          decfsz     count 
          goto     timeit 
          return 
end
 
Last edited by a moderator:

spinnaker

Joined Oct 29, 2009
7,830
Right i have this code below which i need to use as an example to produce my own code i was hoping to do something like a temperature control system ie its too cold; raise temp. its too warm; lower temp. just something really basic but i'm struggling with it because honest to god my lecturer is terrible, to point he might even get the sack :|

please can anyone help me change this code even if its something other than temp control, i just need a basic pic16f88 application and code to go with.

Rich (BB code):
p=16f88 
          portb     equ 0x06 
          porta      equ 0x05 
          trisa      equ 0x85 
          trisb     equ 0x86 
          ansel      equ 0x9b 
          status      equ 0x03 

          count     equ 0x20 
          temp     equ 0x21 
          count2   equ 0x25 
          count22 equ 0x29 
          count25 equ 0x27 
          rotation equ 0x26 
          count3 equ  0x28 
                    org     0x0 
          goto     start 
          org     0x5 
start: 
                banksel     trisb 
          clrf     trisb 
          banksel     portb 
          clrf      portb 

          banksel ansel 
          movlw      0x00 
          movwf      ansel 
          banksel trisa 
          movlw      0x1f 
          movwf      trisa 
sensor1: 
          banksel porta 
checkbit0:      
          btfss      porta,0 
          goto      checkbit1 

 run:        call    stepper1 
             btfss   porta,0 
             goto    checkbit1 
             goto    run 
      
checkbit1:     bcf   portb,2 
             banksel porta 
check1:          btfss      porta,1 
              goto sensor3 

 run2:       call   stepper2 
             btfss  porta,1 
             goto  sensor3 
             goto   run2 
 sensor3: 
             bsf    portb,4 
          goto     sensor1 
stop:           goto stop 
stepper1: 
direction: 
          bsf portb,0 
loop1:      
pulseon: 
             bsf portb,2 
          nop 
pulsedown: 
          bcf  portb,2 
          nop 
pulsegap: 
          movlw     0xff 
          movwf     count2 
timeit3: 
              call    wait 
          decfsz     count2 
          goto     timeit3 
return 
stepper2: 
direction2: 
          bsf  portb,4 
loop2:      
pulseon2: 
             bsf portb,6 
          nop 
pulsedown2: 
          bcf portb,6 
          nop 
pulsegap2: 
          movlw     0xff 
          movwf     count25 
 timeit32: 
              call    wait 
          decfsz     count25 
          goto     timeit32 
          return 
; MAIN BLOCK DELAY: 

wait:      
          movlw     0x01 
          movwf   count 
 timeit: 
          decfsz     count 
          goto     timeit 
          return 
end
First off, any reason that you need to use assembler?

Secondly no one is going to do your work for you. We are glad to help but you are going to have to do most of the work on your own.

Break the problem down into small pieces. For example. If it is temperature control then you will need some kind of temperature sensor. First decide on that,

Then write some code just to "talk" to the sensor. Worry about control later.
 
Top