News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

[Solved] How to get 32 MHz running

Started by keytapper, May 10, 2024, 10:19 AM

Previous topic - Next topic

keytapper

Hello,
I was expecting to get hands on my last project, but a big delusion that it won't start.
Then I went down for troubleshooting the cause and I tested this simple code:
Device = 12F1840
Xtal = 8

Config1 FOSC_INTOSC, WDTE_OFF, PWRTE_ON, MCLRE_OFF, CP_OFF, CPD_OFF, _
BOREN_OFF, CLKOUTEN_OFF, IESO_OFF, FCMEN_OFF
Config2 WRT_OFF, PLLEN_ON, STVREN_OFF,LVP_OFF

Symbol RED PORTA.5
Symbol GRN PORTA.2
OSCCON = %01110010
WDTCON = %00011110
OPTION_REG = 0
WPUA = %00001000
LATA  = 0
TRISA = %00100000
PORTA = 0

Do
    Toggle GRN
    DelayMs 300
    Toggle RED
    DelayMs 500
    Toggle GRN
    DelayMs 300
    Toggle RED
    DelayMs 500
Loop
So I discovered that the delays are 4 times longer than supposed.
I checked all the settings and fuses, but nothing comes out to change.
Config.jpg Configwin.jpg
Looks like that the Configuration words is correct. Maybe I still have an oversight.
I should try to put out a PWM to measure if the clock is what I hope it could be.
Ignorance comes with a cost

tumbleweed

According to the datasheet section 5.2.2.6 you must have OSCCON = %01110000 to use the 4xPLL (SCS<1:0> = 00) with the intosc.


keytapper

Quote from: tumbleweed on May 10, 2024, 11:30 AMOSCCON = %01110000
You're entirely right. I finally discover it, before this post :P.
Ignorance comes with a cost

Pepe

Put xtal = 32 in source and frecuency = 8 in proteus

keytapper

Quote from: Pepe on May 10, 2024, 12:09 PMfrecuency = 8 in proteus
The simulation works very well. I tested with the hardware and I found that I set wrong the SCS in OSCCON as tumbleweed pointed out. Probably I could leave OSCCON alone and just set the PLL fuse.

I still having trouble for a software serial port. The timing seem not well tuned at 9600 baud.
Ignorance comes with a cost

Pepe

In proteus works well