pic16f88 assignment help

Discussion in 'Embedded Systems and Microcontrollers' started by bigbang42, Nov 23, 2012.

  1. bigbang42

    Thread Starter New Member

    Nov 23, 2012
    1
    0
    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.

    Code ( (Unknown Language)):
    1.  
    2. p=16f88
    3.           portb     equ 0x06
    4.           porta      equ 0x05
    5.           trisa      equ 0x85
    6.           trisb     equ 0x86
    7.           ansel      equ 0x9b
    8.           status      equ 0x03
    9.  
    10.           count     equ 0x20
    11.           temp     equ 0x21
    12.           count2   equ 0x25
    13.           count22 equ 0x29
    14.           count25 equ 0x27
    15.           rotation equ 0x26
    16.           count3 equ  0x28
    17.                     org     0x0
    18.           goto     start
    19.           org     0x5
    20. start:
    21.                 banksel     trisb
    22.           clrf     trisb
    23.           banksel     portb
    24.           clrf      portb
    25.  
    26.           banksel ansel
    27.           movlw      0x00
    28.           movwf      ansel
    29.           banksel trisa
    30.           movlw      0x1f
    31.           movwf      trisa
    32. sensor1:
    33.           banksel porta
    34. checkbit0:      
    35.           btfss      porta,0
    36.           goto      checkbit1
    37.  
    38.  run:        call    stepper1
    39.              btfss   porta,0
    40.              goto    checkbit1
    41.              goto    run
    42.      
    43. checkbit1:     bcf   portb,2
    44.              banksel porta
    45. check1:          btfss      porta,1
    46.               goto sensor3
    47.  
    48.  run2:       call   stepper2
    49.              btfss  porta,1
    50.              goto  sensor3
    51.              goto   run2
    52.  sensor3:
    53.              bsf    portb,4
    54.           goto     sensor1
    55. stop:           goto stop
    56. stepper1:
    57. direction:
    58.           bsf portb,0
    59. loop1:      
    60. pulseon:
    61.              bsf portb,2
    62.           nop
    63. pulsedown:
    64.           bcf  portb,2
    65.           nop
    66. pulsegap:
    67.           movlw     0xff
    68.           movwf     count2
    69. timeit3:
    70.               call    wait
    71.           decfsz     count2
    72.           goto     timeit3
    73. return
    74. stepper2:
    75. direction2:
    76.           bsf  portb,4
    77. loop2:      
    78. pulseon2:
    79.              bsf portb,6
    80.           nop
    81. pulsedown2:
    82.           bcf portb,6
    83.           nop
    84. pulsegap2:
    85.           movlw     0xff
    86.           movwf     count25
    87.  timeit32:
    88.               call    wait
    89.           decfsz     count25
    90.           goto     timeit32
    91.           return
    92. ; MAIN BLOCK DELAY:
    93.  
    94. wait:      
    95.           movlw     0x01
    96.           movwf   count
    97.  timeit:
    98.           decfsz     count
    99.           goto     timeit
    100.           return
    101. end
    102.  
     
    Last edited by a moderator: Nov 23, 2012
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    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.
     
Loading...