PDA

View Full Version : Oscillator question and measurement



Christopher4187
- 24th February 2013, 20:47
I only had a PIC in a QFN package but wanted to make a protoype with it. What I did was strip a 24 gauge wire and solder each individual strand to each pin. I'm never doing that again but.....

It seems slower than what it should be. I want to determine if it's the hardware or software so I used this:

Start:
TOGGLE portd.1
PAUSEUS 1
GOTO start

I have a 20 MHz crystal and DEFINE OSC 48. When I measure the frequency, am I supposed to get 1MHz? I get about 374 KHz. One thing that may be causing this is, to stabilize the soldering, I put hot glue on all of the pins not realizing that it's probably putting a little resistance between the oscillator pins.

Any ideas?

rsocor01
- 24th February 2013, 21:02
Hi,

Get rid of the line "PAUSEUS 1" and tell us what happens.

Acetronics2
- 24th February 2013, 21:04
some JELT pcb " Tropicoat " protective varnish makes real good glue ... did you also try nail lacquer ??? ( NO metallic colour !!! - of course -)

a simulator run would show your program NEVER will run @ 1 Mhz ... as TOGGLE and GOTO commands need some time to execute

we also must suppose your Pic is a 18F series for the Pauseus1 to be equal to 1µs ...

Now, Hot glue doesn't disturb the oscillator in any way ...

Alain

Christopher4187
- 24th February 2013, 21:27
Get rid of the line "PAUSEUS 1" and tell us what happens.I didn't have a scope handy and the meter I had isn't able to calculate high frequencies. I'll be able to try that tonight. What should I expect to see with just a toggle command?


we also must suppose your Pic is a 18F series for the Pauseus1 to be equal to 1µs ...Yes, it's an 18F4550. The program works but the CAN data isn't flowing smoothly compared to the previous devices I made. All of the pinouts are different, and wanted to rule that out, but I can't even see how that would cause slow CAN data in the first place.

Acetronics2
- 24th February 2013, 22:03
a little MPSIM ( MPLAB ) simulation - supposed to be relatively true - gives à 3.2µs half -cycle to your test ... around 160 khz output frequency !
BTW ... I'm not sure the DEFINE OSC 48 and a 20 Mhz Xtal to be a good combination ...

best result @ 1.8µs half cycle given by
Portb.1 = ! Portb.1 instead of TOGGLE + PAUSEUS1

Christopher4187
- 25th February 2013, 02:11
Here are the results. Are these typical?



start:
pauseus 1
toggle portd.1
goto start 375 KHz



start:
toggle portd.1
goto start 1 MHz


start:
Portb.1 = ! Portb.1
goto startThis does nothing


start:
portd.1=1
portd.1=0
goto start3 MHz

Acetronics2
- 25th February 2013, 19:47
start:
Portb.1 = ! Portb.1
goto startThis does nothing


Sure it does not show anything on portD1 ... :rolleyes:

Alain

Christopher4187
- 25th February 2013, 19:53
I know. I was too lazy to edit it yesterday. My original comment still stands.

Acetronics2
- 25th February 2013, 20:59
ohhh ... may be the RMW issue ...

due to a 18F chip ... I should have written:



start:
latb.1 = ! latb.1
goto start


on test with the EP5 tomorrow morning ...

rsocor01
- 26th February 2013, 06:43
I didn't have a scope handy and the meter I had isn't able to calculate high frequencies. I'll be able to try that tonight. What should I expect to see with just a toggle command?

I think the problem is that you are not configuring the fuses of the PIC correctly. Are you also setting the OSCON register? I use a 4MHz crystal with my 18F4550 and to make it work the first time it was a pain.

Acetronics2
- 26th February 2013, 14:44
Results of the test ...

output freq is exactly that expected ... and that MPSIM shows ....

111.1 Khz with a 8 Mhz Xtal
277.7 Khz with a 20 Mhz Xtal

sooo ... getting 1 Mhz output looks a bit too much !!! - gives 72 Mhz @ Clock - 18Mhz Xtal and PLL x 4 ; that looks real hard overclocking for such chips ...
MAY BE POSSIBLE, but with very light loads on the output ...

Alain

Acetronics2
- 26th February 2013, 15:19
Results of the test ...

output freq is exactly that expected ... and that MPSIM shows ....

111.1 Khz with a 8 Mhz Xtal
277.7 Khz with a 20 Mhz Xtal
666.5 Khz with 48 Mz @ Clock
833.1 Khz with ... 60Mhz ( poor USB clock ! )
looks a bit over 1Mhz with ... 80Mhz ( poor ... etc )



#CONFIG

__CONFIG _CONFIG1L, _PLLDIV_3_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; ; ; USB clock source comes from the 96 MHz PLL divided by 2
; ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
; 1/2 prescale


__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
; ; ; Oscillator Switchover mode disabled
; ; Fail-Safe Clock Monitor disabled
; HS oscillator, PLL enabled, HS used by USB
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L

__CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L
__CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
__CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
__CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H & _WRTD_OFF_6H
__CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L &_EBTR2_OFF_7L &_EBTR3_OFF_7L
__CONFIG _CONFIG7H, _EBTRB_OFF_7H


#ENDCONFIG

trisa = 0
trisb = 0
trisc = 0
trisd = 0
lata = 0
latb = 0
latc = 0
latd = 0

Start:
Latb.1 = ! Latb.1
GOTO start
END



some surely will throw me everything that can fly .... LOL !

sooo ... getting 1 Mhz output looks a bit too much though !!! - gives 72 Mhz @ Clock - 18Mhz Xtal and PLL x 4 ; that looks real hard overclocking for such chips ...
MAY BE POSSIBLE, but with very light loads on the output ...

I did it ... so any idiot can do it too ...

the 4550 did not die ... really nice chip, isn't it ???

Alain

PS: this "timeout" really is a shame, Lester ....