Internal Clock setting for PIC16F690

Discussion in 'Embedded Systems and Microcontrollers' started by lmartinez, Jun 13, 2009.

  1. lmartinez

    Thread Starter Active Member

    Mar 8, 2009
    224
    6
    I would like to have assistance with the assembly code shown below. I am trying to set the internal oscillator clock for the PIC16F690 to 8Mhz and it is not working? Please advice and thank you in advance



    #include <p16F690.inc>
    __config (_INTRC_OSC_NOCLKOUT &_WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)

    cblock 0x20
    Delay1 ; Define two file registers for the
    Delay2 ; delay loop
    endc

    org 0
    Start:
    bcf STATUS, RP1
    bsf STATUS,RP0 ; select Register Page 1
    movlw 0b01110001 ;OSCCON = 0b01110001
    movwf OSCCON

    bcf TRISC,0 ; make IO Pin C.0 an output
    bcf STATUS,RP0 ; back to Register Page 0
    clrf Delay1
    MainLoop:
    bsf PORTC,0x00 ;Turn on LED C0


    OndelayLoop:
    nop
    nop
    nop

    ;decfsz Delay1,f ; Waste time.
    ;goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
    ;decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
    ;goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
    ; call it a two-tenths of a second.

    bcf PORTC,0 ; Turn off LED C0
    OffDelayLoop:
    nop

    ;decfsz Delay1,f ; same delay as above
    ;goto OffDelayLoop
    ;decfsz Delay2,f
    ;goto OffDelayLoop
    goto MainLoop ; Do it again...
    end
     
Loading...