Вы находитесь на странице: 1из 4

22/1/2015

(SOLUCIONADO)ClculodetiemposC18(CRYSTAL)

(SOLUCIONADO)ClculodetiemposC18(CRYSTAL)
<<<(2/2)
jukinch:
Probhacerunapruebarealconlaslibrerasderetardosparaunlapsodetiempoconocidoyluegoconel
osciloscopiolocontrols.
libreradelays.h.
Enellatens4funciones:
Delay10TCYx(i)>10.Tcy.igeneraunademorade10ciclosdeinstrucciones*i
Delay100TCYx(i)>100.Tcy.igeneraunademorade100ciclosdeinstrucciones*i
Delay1KTCYx(i)>1000.Tcy.igeneraunademorade1000ciclosdeinstrucciones*i
Delay10KTCYx(i)>10000.Tcy.igeneraunademorade10000ciclosdeinstrucciones*i
ipuedetomarunvalorde1a255.(ojoSisetomavalor0ies256)
Paracalculareltiempodebstenerencuentalafrecuenciaalaquetrabajaelpic
TCYsecalculacomo4/fosc
dondefosc=frecuenciadeoscilador
Ejemplode4mhz
Enestecaso4*10^6(4MHz),
porlotantoTCY4/4000000=1/10^6=0,000001sec
1TCY=0,000001seg
1.000.000TCY=1seg
paracalcularunsegundo
1seg*1TCY
=1.000.000TCYs
0,000001seg

calculodelvalordeiusandolafuncinDelay10KTCYx(i)=iequivalea10000TCYs
1.000.000TCYs
=100i
10.000TCY
http://www.todopic.com.ar/foros/index.php?topic=37359.5wap2

1/4

22/1/2015

(SOLUCIONADO)ClculodetiemposC18(CRYSTAL)

Delay10KTCYx(100)//dura1seg

ejemploconfrecuenciade20mhz
TCYsecalculacomo4/fosc
Enestecaso20*10^6(20MHz),porlotantoTCY=4/20*10^6=0,0000002
1TCY==0,0000002seg
paracalcularunsegundo
1seg*1TCY
=5.000.000TCYs
0,0000002seg
calculodelvalordeiusandolafuncinDelay10KTCYx(i)=iequivalea10000TCYs
5.000.000TCYs
=500i
10.000TCY
divido500entre255paraseparareltiempoennDelay10KTCYx(i)yaqueisolopuedetomarvaloresde1a
255

Delay10KTCYx(255)//usandolosdosdelayllegoalsegundo
Delay10KTCYx(245)//
_LAB_:
Holajukinch!!!
Graciasporcontestar!!!
Hicetodoloquedijisteperolaspruebasycalculosusandounoscexternode16Mhz(talcomoelinicio)y
supuestamentellevandoloalos48Mhznofuncionancomoyasuponia!!!
Loscalculosquehicefueron:
Considerandoosc48Mhz:
Delay10KTC=10000*4/(48*10^6)=0.00083333
1sg/0.00083333=1200/5=240
Estonoandubonicerca
Usandoosca16Mhz:
Delay10KTC=10000*4/(16*10^6)=0.0025
1sg/0.0025=400/2=200
Asifunciono!!!
http://www.todopic.com.ar/foros/index.php?topic=37359.5wap2

2/4

22/1/2015

(SOLUCIONADO)ClculodetiemposC18(CRYSTAL)

Resumiendo...SigoconelproblemaquealparecerelPICtrabajaa16Mhzynoalos48Mhz
EntoncesQueestoyconfigurandomal?
LeieltemadelosfusesdeconfiguracionqueentregaC18ybuenoakilosposibles>
PLLPrescalerSelectionbits:
PLLDIV=12Divideby12(48MHzoscillatorinput)
PLLDIV=10Divideby10(40MHzoscillatorinput)
PLLDIV=6Divideby6(24MHzoscillatorinput)
PLLDIV=5Divideby5(20MHzoscillatorinput)
PLLDIV=4Divideby4(16MHzoscillatorinput)
PLLDIV=3Divideby3(12MHzoscillatorinput)
PLLDIV=2Divideby2(8MHzoscillatorinput)
PLLDIV=1Noprescale(4MHzoscillatorinputdrivesPLLdirectly)

CPUSystemClockPostscaler:
CPUDIV=OSC4_PLL6CPUsystemclockdivideby6
CPUDIV=OSC3_PLL3CPUsystemclockdivideby3
CPUDIV=OSC2_PLL2CPUsystemclockdivideby2
CPUDIV=OSC1NoCPUsystemclockdivide

Oscillator:
OSC=INTOSCINTOSC
OSC=INTOSCOINTOSCO(CLKORA6)
OSC=INTOSCPLLINTOSCPLL
OSC=INTOSCPLLOINTOSCPLLO(CLKORA6)
OSC=HSHS,USBHS
OSC=HSPLLHS+PLL,USBHS+PLL
OSC=ECEC(CLKORA6),USBEC
OSC=ECPLLEC+PLL(CLKORA6),USBEC+PLL
Creoqueesossonlosimportantes
Ahorayosiempreheusado
OSC=HSPLL
PLLDIV=4
CPUDIV=OSC1
Enladatasegunveoestariatrabajandoalos48Mhz.
AhoralasunicasdudasquetendriaseriaelPLLEN(multiplexor)sehabilitaalusarHSPLL
yrespectoalotroelFOSCyOSCCONnosequepasaraconellos!!
Sialguiensabequeestoyhaciendomalporfavor
jukinchnosesiseteocurrealgo....
Buenograciasporlasrespuestasyesperoquealguienmeayudeaencontrarlasolucionamidilema!!!

_LAB_:
http://www.todopic.com.ar/foros/index.php?topic=37359.5wap2

3/4

22/1/2015

(SOLUCIONADO)ClculodetiemposC18(CRYSTAL)

AcabodedescibriralgointeresanteresultaqueelregistroOSCTUNEcontrolaalgunosaspectosdeloscilador
EspecificamenteparamiintereselregistroPLLEN>sinembargoenlasimulacionrevisandolosregistrosveo
queesteregistrosemantienesiempreenceroesdecirnuncahabilitaelPLL....
Raroquesucedera???
VoyaintentarhabilitarelPLL"manualmente"sinembargonopuedoverlosregistrosdeconfiguraciondonde
estaalojadalaconfiguraciondelPLLDIV,CPDIVyFOSC...
Sialguiensabecomoverestosregistros...queseatanamabledeavisar!!!!gracias!!!
_LAB_:
Enhorabuenajjajajaja!!!!:/
EraesoelregistronoeramodificadoautomaticamentealactivarelHSPLLporloquenuncahabiahabilitadoel
PLLynadasabemosloquepasaba!!!
Muchasgraciasjukinchporayudarme!!!!
Mesirvierontusconsejos!!
Saludos!!!!
jukinch:
Quebuenoqueencontrastesolucin.Ahoraaprogramaresepic)
Saludos
Jukinch
Navegacin
[0]ndicedeMensajes
[*]PginaAnterior

http://www.todopic.com.ar/foros/index.php?topic=37359.5wap2

4/4

Вам также может понравиться