48MHz lassen sich nicht einstellen

Support-Forum für Deutschsprachige, die in ihrer Muttersprache schreiben möchten.

Moderator: Benj

Post Reply
HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,

Ich habe einen PIC 18F25J50 und möchte diesen mit einer Frequenz von 48MHz betreiben.
Am 18F25J50 ist ein externes 12MHz Quarz angeschlossen.
Leider lässt sich der PIC nicht auf 48MHz einstellen, weder intern noch extern (siehe Anhang).

Laut meinem Oszilloskop hätte ich am Ausgang 8.33Hz statt 100Hz bei einer eingestellten Frequenz von 48MHz im “Projekt Optionen“ Fenster. Erst wenn ich 4MHz im “Projekt Optionen“ Fenster einstelle erhalte ich die richtige Frequenz von 100Hz.

Was mache ich falsch.

mit freundlichen Grüßen
HjH
USB_Test_1.zip
(54.16 KiB) Downloaded 387 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by Benj »

Hallo,

Bitte können Sie versuchen, den folgenden Code in ein C-Code-Symbol am Anfang Ihres Programms. Die PLL auf der J50-Geräte nicht tatsächlich von der Konfiguration aktiviert bekommen und muss manuell per Software gestartet werden. Ihre Konfigurationseinstellungen korrekt aussehen.

Code: Select all

unsigned int pll_startup_counter = 600;
OSCTUNEbits.PLLEN = 1;  //Aktivieren Sie die PLL und warten 2 + ms, bis die PLL Schleusen vor dem Aktivieren der USB-Modul
while(pll_startup_counter--);
Dieser Code wird automatisch für den 18F6XJ50, 18F8XJ50, 18F8XJ55 und 18F8XJ55 Geräte als Teil der USB-Komponenten enthalten.


Hello,

Please can you try adding the following code into a C code icon at the start of your program. The PLL on the J50 devices does not actually get activated by the configuration and has to be manually started by software. Your configuration settings look correct.

Code: Select all

unsigned int pll_startup_counter = 600;
OSCTUNEbits.PLLEN = 1;  //Enable the PLL and wait 2+ms until the PLL locks before enabling USB module
while(pll_startup_counter--);
This code is automatically included for the 18F6XJ50, 18F8XJ50, 18F8XJ55 and 18F8XJ55 devices as part of the USB components.

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hello,

ich habe Ihren Programmabschnitt in mein Programm eingefügt.
Daraufhin bekam ich folgende Fehlermeldung:

USB_Test_1.c(177:2): error: unknown identifier 'OSCTUNEbits'
USB_Test_1.c(177:2): error: failed to generate expression
USB_Test_1.c(177:2): error: invalid operand 'OSCTUNEbits.0x00000006'
USB_Test_1.c(177:25): error: failed to generate expression

Daraufhin habe ich folgende Programmzeile unter „ergänzenden Code“ eingefügt

volatile char _pllen @PLLEN;

Jetzt startet zwar das Programm ohne Fehler aber die Einstellungen haben keinen Einfluss auf den Takt.

mit freundlichen Grüßen
HjH
USB_Test_1.zip
(20.86 KiB) Downloaded 384 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by Benj »

Hallo,

Leider mein Fehler, war der Code, den ich geliefert für einen anderen Compiler. Dieser Code sollte korrekt funktionieren unter BoostC.

Code: Select all

unsigned int pll_startup_counter = 600;
set_bit(OSCTUNE, PLLEN);  //Aktivieren Sie die PLL und warten 2 + ms, bis die PLL Schleusen vor dem Aktivieren der USB-Modul
while(pll_startup_counter--);
Hello,

Sorry my mistake, the code I supplied was for another compiler. This code should work correctly under BoostC.

Code: Select all

unsigned int pll_startup_counter = 600;
set_bit(OSCTUNE, PLLEN);  //Aktivieren Sie die PLL und warten 2 + ms, bis die PLL Schleusen vor dem Aktivieren der USB-Modul
while(pll_startup_counter--);

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,

leider bekomme ich folgende Fehlermeldung nach dem ich Ihren Programmschnipsel eingesetzt habe:

USB_Test_1.c(171): error: left operand must be l-value
USB_Test_1.c(171:16): error: failed to generate expression

Daraufhin habe ich folgende Programmzeilen eingefügt

volatile char _pllen @PLLEN;
unsigned int pll_startup_counter = 600;

set_bit(osctune, _pllen);
while(pll_startup_counter--);

Jetzt startet zwar das Programm ohne Fehler aber die Einstellungen haben keinen Einfluss auf den Takt.

mit freundlichen Grüßen
HjH
USB_Test_1.zip
(20.77 KiB) Downloaded 376 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by medelec35 »

Hi HjH

Code: Select all

set_bit(OSCTUNE, PLLEN);
Is causing error.

You need to either use

Code: Select all

set_bit(osctune,PLLEN);
or

Code: Select all

osctune.PLLEN=1; 
Both do the same thing.

Note both commands are case sensitive. Where I have used upper case and lower case, you must too.

Martin
Martin

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hi,
ich habe die Befehlszeile in mein Programm eingefügt.
Leider hat dies keine Auswirkungen auf den Takt.

Mit freundlichen Grüßen
HjH

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by medelec35 »

Altered as I have suggested.
Compiles OK for me with V4.5.

Martin
Attachments
USB_Test_1 Mod.fcf
(4.5 KiB) Downloaded 349 times
Martin

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,

das modifizierte Programm ändert den Takt nicht.

Das Problem dürfte daran liegen, dass keine Konfiguration mit dem Hex-File übertragen wird.
Was muss ich einstellen damit die Konfiguration mit übertragen wird.

Mit freundlichen Grüßen
HjH

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by Benj »

Hallo,

Ich bin derzeit dabei, das Problem auf einem 18F26J50 Gerät so ich euch, wie ich auf zu bekommen.


Hello,

I am currently looking into the problem on a 18F26J50 device so I will let you know how I get on.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by Benj »

Hallo,

Ich glaube, ich habe es geschafft, das Problem zu lösen, scheint es eine Reihe von Fragen alle, die sich aus der Tatsache, dass Microchip falsche Informationen in ihren Datenblättern für die J50 Familien zur Konfiguration Adresse sein. Ich habe jetzt eine 18F26J50 läuft bei 48MHz: D

So, um dieses Problem zu beheben das erste, was Sie tun müssen, ist die Aktualisierung der PPP 18F Konfigurationsdatei zu diesem Download nicht diese Datei und legen Sie es in Ihren "Flowcode v4 \ Tools \ PPP"-Verzeichnis.
ppp_config_data3.cfg
(1.49 MiB) Downloaded 402 times
Als nächstes haben wir die Flowcode-Definitions-Dateien, dies zu tun laden Sie das Archiv zu aktualisieren und extrahieren Sie die FCD-Dateien in Ihr "Flowcode \ FCD"-Verzeichnis.
18FxxJ50.zip
(19.85 KiB) Downloaded 384 times
Als Randnotiz in der Standalone-PICkit 3 Dienstprogramm das Konfigurationsmenü für die J50-Geräten scheint zu sein, völlig falsch. Das PICkit 2 Software scheint die richtige Maskierung haben. : D

Der C-Code für BoostC, damit die PLL ist wie folgt.

Code: Select all

unsigned int pll_startup_counter = 600;
set_bit(osctune, PLLEN);  //Aktivieren Sie die PLL und warten 2 + ms, bis die PLL Schleusen vor dem Aktivieren der USB-Modul
while(pll_startup_counter = pll_startup_counter - 1);
Lassen Sie mich wissen, wie Sie zu erhalten.


Hello,

I think I have managed to solve the problem, there seem to be a number of issues all stemming from the fact that Microchip have incorrect information in their datasheets for the J50 families regarding configuration address. I now have a 18F26J50 running at 48MHz :D

So to fix this the first thing you have to do is update the PPP 18F config file, to do this download this file and drop it into your "Flowcode v4\Tools\PPP" directory.
ppp_config_data3.cfg
(1.49 MiB) Downloaded 402 times
Next we have to update the Flowcode definition files, to do this download the archive and extract the FCD files into your "Flowcode\FCD" directory.
18FxxJ50.zip
(19.85 KiB) Downloaded 384 times
As a side note in the standalone PICkit 3 utility the configuration setup for the J50 devices seems to be completely incorrect. The PICkit 2 software seems to have the correct masking. :D

The C code for BoostC to enable the PLL is as follows.

Code: Select all

unsigned int pll_startup_counter = 600;
set_bit(osctune, PLLEN);  //Aktivieren Sie die PLL und warten 2 + ms, bis die PLL Schleusen vor dem Aktivieren der USB-Modul
while(pll_startup_counter = pll_startup_counter - 1);
Let me know how you get on.

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,

irgendetwas mache ich falsch. Denn der Takt ändert sich weder, wenn ich über den PICKIT 3 noch über PICKIT 2 das Hex-Programm laden.
Das PICKIT 2 zeigt wenigstens einen Fehler an „Hex-File enthält keine Konfiguration“. Das PICKIT 3 zeigt keinen Fehler an.

Ich habe das File „ppp_config_data3.cfg“ in das Verzeichnis „ …\Matrix Multimedia\Flowcode V4\Tools\PPP “ gestellt. Danach kopierte ich die Dateien aus „18FxxJ50.zip“ in das Verzeichnis
„ …\Matrix Multimedia\Flowcode V4\FCD “. Den Programmabschnitt „set_bit(osctune, PLLEN);” aktualisierte ich. Trotzdem änderte sich nicht der Takt.

Mit freundlichen Grüßen
HjH

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by Benj »

Hallo,

Unter Umständen müssen Sie auf dem Chip -> Konfigurieren und vielleicht ändern Sie eine der Einstellungen, dann ändern Sie es zurück, wie man es hatte, und klicken Sie dann auf OK. Dies sollte dann laden Sie die neue Konfiguration in Ihr C-Code-Datei, wenn Sie kompilieren C. Der obere Teil der C-Datei sollte etwa so aussehen.

Code: Select all

//Configuration data
#ifdef _BOOSTC
#pragma DATA 0xfff8, 0xba
#endif
#ifdef _HI_TECH_C
%C__CONFIG(%A, %V);
#endif
#ifdef _BOOSTC
#pragma DATA 0xfff9, 0xff
#endif
#ifdef _HI_TECH_C
%C__CONFIG(%A, %V);
#endif
#ifdef _BOOSTC
#pragma DATA 0xfffa, 0xf5
#endif
...
Wenn Ihre Adressen noch 0x300000 dann die Änderungen wurden nicht korrekt geladen.

Das PICkit 2-Software sollte nicht werden, was Ihnen die fehlenden Informationen Config-Fehler, wenn die richtige Config-Daten in die C-Datei geladen wurde.


Hello,

You may have to click on the Chip -> Configure and maybe change one of the settings, then change it back how you had it and then click ok. This should then load the new config settings into your C code file when you compile to C. The top of the C file should look something like this.

Code: Select all

//Configuration data
#ifdef _BOOSTC
#pragma DATA 0xfff8, 0xba
#endif
#ifdef _HI_TECH_C
%C__CONFIG(%A, %V);
#endif
#ifdef _BOOSTC
#pragma DATA 0xfff9, 0xff
#endif
#ifdef _HI_TECH_C
%C__CONFIG(%A, %V);
#endif
#ifdef _BOOSTC
#pragma DATA 0xfffa, 0xf5
#endif
...
If your addresses are still 0x300000 then the changes have not been loaded correctly.

The PICkit 2 software should not be giving you the missing config information error when the correct config data has been loaded into the C file.

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,

irgendetwas ist beim kopieren falsch gelaufen. Es existieren keine Konfigurations-Daten mehr in der C-Datei.
Was muss ich ändern damit ich diesen Zustand rückgängig machen kann.

Mit freundlichen Grüßen
HjH

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,

zum besseren Verständnis hier die Projektdateien.
USB_Test_1_Mod.zip
(54.41 KiB) Downloaded 353 times

HjH
Posts: 108
Joined: Sat Jul 03, 2010 4:38 pm
Been thanked: 2 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by HjH »

Hallo,
ich konnte das Problem beheben. Die 48MHz Taktfrequenz lassen sich jetzt einstellen.

Vielen Dank für die Hilfe

Mit freundlichen Grüßen
HjH

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: 48MHz lassen sich nicht einstellen

Post by Benj »

Hallo HJH,

Danke, dass es uns wissen. Glad seine Arbeitsmethoden richtig für dich.


Hi HJH,

Thanks for letting us know. Glad its working correctly for you now.

Post Reply