Bonjour,
je voudrais utiliser les PWM pour faire un générateur de sons, basses fréquences ' 1Hz à 1KHz' par exemple.
J' ai vu que le PIC18F4331 a plusieurs sorties PWM
Problème : la fréquence d'horloge par quartz (HS)que j'utilise généralement, est de 1MHz au minimum, d'où la fréquence d'un PWM au minimum, est de 60Hz pas assez basse pour mon projet.
Dans la datasheet du PIC, il parle de l'horloge interne :
• Internal oscillator block:
- 8 user selectable frequencies: 31 kHz to 8 MHz
- OSCTUNE can compensate for frequency drift
• Secondary oscillator using Timer1 @ 32 kHz
(à partir de 125 kHz à 4 MHz) pour un total de huit
fréquences d'horloge.
Mais comment utiliser l'oscillateur interne????? avec Flowcode 6.1.2 et donc de choisir sa fréquence???
si j'ai bien lu il faut agir sur "OSCCON" mais comment on fait?
Bien à vous
oscillateur interne
Moderator: Benj
- 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: oscillateur interne
Bonjour,
La première chose que vous devez faire est d'ajouter une icône de code C pour le début de votre macro principal . A l'intérieur de l'icône de code C ajouter la ligne de code suivante .
Repace xxx avec la vitesse d'horloge que vous souhaitez utiliser .
0x70 - 8 MHz
0x60 - 4MHz
0x50 - 2MHz
0x40 - 1MHz
0x30 - 500KHz
0x20 - 250KHz
0x10 - 125KHz
0x00 - 32KHz
par exemple
Ensuite, allez dans les options du projet et de modifier la vitesse d'horloge en fonction de votre taux choisi . Cela devrait permettre à des retards et bauds etc pour être calculées correctement .
Enfin aller dans l'onglet de configuration des options du projet et changer le type d'oscillateur à la mise INT-RC Port .
Hello,
The first thing you will need to do is add a C code icon to the start of your Main macro. Inside the C code icon add the following line of code.
Repace xxx with the clock speed you wish to use.
0x70 - 8MHz
0x60 - 4MHz
0x50 - 2MHz
0x40 - 1MHz
0x30 - 500KHz
0x20 - 250KHz
0x10 - 125KHz
0x00 - 32KHz
e.g.
Next go into the project options and change the clock speed to match your chosen rate. This should allow delays and bauds etc to be calculated correctly.
Finally go into the configure tab of the project options and change the oscillator type to the INT-RC Port setting.
La première chose que vous devez faire est d'ajouter une icône de code C pour le début de votre macro principal . A l'intérieur de l'icône de code C ajouter la ligne de code suivante .
Code: Select all
osccon = osccon | xxx;
0x70 - 8 MHz
0x60 - 4MHz
0x50 - 2MHz
0x40 - 1MHz
0x30 - 500KHz
0x20 - 250KHz
0x10 - 125KHz
0x00 - 32KHz
par exemple
Code: Select all
osccon = osccon | 0x40;
Enfin aller dans l'onglet de configuration des options du projet et changer le type d'oscillateur à la mise INT-RC Port .
Hello,
The first thing you will need to do is add a C code icon to the start of your Main macro. Inside the C code icon add the following line of code.
Code: Select all
osccon = osccon | xxx;
0x70 - 8MHz
0x60 - 4MHz
0x50 - 2MHz
0x40 - 1MHz
0x30 - 500KHz
0x20 - 250KHz
0x10 - 125KHz
0x00 - 32KHz
e.g.
Code: Select all
osccon = osccon | 0x40;
Finally go into the configure tab of the project options and change the oscillator type to the INT-RC Port setting.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: oscillateur interne
Bonjour Benj ,
j'ai testé avec un PIC18F4520 sans résultat.
normalement je dois avoir une sortie PWM en RC2 mais il n'y a rien.
voici le programme test voici les configurations INT RC et vitesse : j'ai aussi mis une résistance de 100K de RC2 vers la masse, pour la sortie PWM0.
pas d'erreur signalée à la compile.
Ai-je oublié quelque chose???
Bien à toi
j'ai testé avec un PIC18F4520 sans résultat.
normalement je dois avoir une sortie PWM en RC2 mais il n'y a rien.
voici le programme test voici les configurations INT RC et vitesse : j'ai aussi mis une résistance de 100K de RC2 vers la masse, pour la sortie PWM0.
pas d'erreur signalée à la compile.
Ai-je oublié quelque chose???
Bien à toi
- 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: oscillateur interne
Bonjour,
Les options de configuration suivantes doivent être réglés sur désactivé.
Watchdog Timer
Programme basse tension
CPU Extended Activer
Espérons que cela devrait résoudre le problème .
Hello,
The following config options should be set to disabled.
Watchdog Timer
Low Voltage Program
Extended CPU Enable
Hopefully this should solve the problem.
Les options de configuration suivantes doivent être réglés sur désactivé.
Watchdog Timer
Programme basse tension
CPU Extended Activer
Espérons que cela devrait résoudre le problème .
Hello,
The following config options should be set to disabled.
Watchdog Timer
Low Voltage Program
Extended CPU Enable
Hopefully this should solve the problem.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel