Re: PIC timing




"randy.day" <randy.day@xxxxxxxx> wrote in message
news:nTedj.29074$DP1.13331@xxxxxxxxxxxx
Okay, I was curious about the actual speed my controller
is running at, so I ran the following loop on it. If I'm not mistaken,
I've set OSCCON to 8MHz, so at 4 clock/instruction I should see
0.5 uS pulses. My scope on RB4 shows pulses 5uS wide!

I'm out by a factor of 10. What have I not taken into account?


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

Org 0
goto Start
Org 4
goto ISR
ISR
retfie

Start movlw 0x71 ;b'01110001'
BANKSEL OSCCON
movwf OSCCON

; initialize any register that might affect I/O
BANKSEL IOCB
clrf IOCB
clrf WPUB
clrf ANSEL
clrf ANSELH

BANKSEL TRISA
clrf TRISA ; PORTA all output
clrf TRISB ; PORTB all output
clrf TRISC ; PORTC all output

BANKSEL SSPCON
bcf SSPCON, 5

;=== run timing loop ===
BSF PORTB,4
BCF PORTB,4
goto $-2
end



The "goto $-2" takes two instruction times.
I make it as, (in 0.5uS steps and 0V,5V) ...
5-0-0-0-5-0-0-0-5-0-0-0-5-0-0-0-5 ...
I.e. 2uS repetition (500kHz), at a 1:3 duty cycle with 8MHz clock=2 mips.





.



Relevant Pages

  • Re: PIC timing
    ... I've set OSCCON to 8MHz, so at 4 clock/instruction I should see ... goto ISR ... clrf IOCB ... If you are only measuring the part of the pulse that is high, ...
    (sci.electronics.basics)
  • Re: Tiny Bootloader
    ... JohnT wrote: ... All I'm doing after it goes to the INIT routine is set all the outputs ... ;clrf STATUS ... goto Main ...
    (comp.arch.embedded)
  • PIC timing
    ... goto ISR ... clrf IOCB ... BANKSEL TRISA ... BANKSEL SSPCON ...
    (sci.electronics.basics)
  • Re: Tiny Bootloader
    ... If I don't put a GOTO in first four instructions it does indeed warn me ... that there isn't a GOTO instruction. ... ;clrf STATUS ...
    (comp.arch.embedded)