Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need help understanding the clocking frequency... not a hard question :)

Status
Not open for further replies.

erospawn

New Member
With the following code, the clocking frequency would be 1Mhz with a 4Mhz clock, correct? If I were using TMR0 with prescaler at 1:2 my oveflow frequency would be 4Khz with a period of 2us?

list P=16f630
#include <p16f630.inc>
__config _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CP_OFF

cblock 20h
BH,BL,wait,del_clk1,del_clk2,run,runn,count
endc

RESET_VECTOR CODE 0X000
goto main

main


bsf STATUS,RP0 ;bank 1
call 0x3ff
movwf OSCCAL
movlw 0x00
movwf TRISC ;make all PORTC outputs
movlw 0xfD
movwf TRISA ;make all PORTA inputs
movlw 0x00
movwf OPTION_REG
bcf STATUS,RP0
CLRF TMR0
BCF INTCON,5
movlw 0x07 ;turn off comparitors
movwf CMCON
 
eros, Keep in mind that the calculation is with a preload of 0. If you preload TMR0 with 131 you'll get your 4KHz frequency (250 µs period).
 
Status
Not open for further replies.

Latest threads

Back
Top