PIC12F629 programming

Discussion in 'Embedded Systems and Microcontrollers' started by forester, Sep 20, 2010.

  1. forester

    Thread Starter New Member

    Sep 20, 2010
    1
    0
    Please help me solve this task, if possible send answers to e-mail <snip>

    You need to analyze the following program listing and find the following:
    A – number of instruction cycles for EastLoop block
    B – number of instruction cycles for NordLoop block
    C – number of times diod connected to 6th pin will light on

    Code ( (Unknown Language)):
    1.  
    2.  
    3. #include
    4.    __config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF)
    5.  
    6.    cblock 0x20
    7. Delay1
    8. Delay2
    9. Delay3
    10.     endc
    11.  
    12.     org 0
    13. Start:
    14.     bsf       STATUS,RP0
    15.     clrf      TRISIO
    16.     bcf       STATUS,RP0
    17.     clrf       Delay1
    18.     clrf       Delay2
    19.     clrf       Delay3
    20.     movlw     0xD0
    21.     movwf     B'100000'
    22.     movlw     .7
    23.     movwf     CMCON
    24. MainLoop:
    25.     bsf       GPIO,GP1
    26.     bsf       0x21,5
    27. EastLoop:
    28.     nop
    29.     decfsz    Delay1,f
    30.     goto      EastLoop
    31.     decfsz    Delay2,f
    32.     goto      EastLoop
    33.     movwf     Delay3
    34.     bcf       0x05,1
    35.     bsf       0x05,4
    36.     decf      Delay3,0
    37.     bsf       0x20,7
    38.     bsf       0x20,3
    39.     bsf       O'40',1
    40.     comf      .32,1
    41. NordLoop:
    42.     decfsz    Delay1,f
    43.     goto      NordLoop
    44.     btfsc     GPIO,GP1
    45.     goto      SetStep
    46.     bsf       GPIO,GP1
    47.     goto      SetSStep
    48. SetStep:
    49.     bcf       GPIO,GP1
    50. SetSStep:
    51.     decfsz    Delay3,f
    52.     goto      NordLoop
    53.     bcf       0x05,1
    54.     bcf       0x05,4
    55.     end
    56.  
    57.  
     
    Last edited by a moderator: Sep 20, 2010
  2. debjit625

    Well-Known Member

    Apr 17, 2010
    790
    186
    Check out PIC12F629's Datasheet from Microchip's website.In datasheet you will find all the instruction's instruction cycles .

    Good Luck
     
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    Just use the MPlab simulator and the stopwatch. Make sure you set the device frequency to 4MHz.
     
  4. eblc1388

    Senior Member

    Nov 28, 2008
    1,542
    102
    Why?

    Will the answer be different if other frequencies are being use?
     
  5. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    True, I didn't read the questions properly. It doesen't matter for instruction cycles.
     
Loading...