Bonjour tout le monde, je dois faire un programme qui génère un pwm avec rapport cyclique variable. j'ai fait ce programme qui s'execute mais j'ai rien comma signal sur CCCP2 de pic 18F4550 pouvez vous vous me dire pourquoi ne fonctionne pas.//INCLUDES
#include "p18f4550.h"
#include "stdio.h"
//Configuration Bits
#pragma const config FCMENB = OFF //Fail Safe Clock Monitor Disabled
#pragma const config IESOB = OFF //Internal External Osc. Switch Disabled
#pragma config PWRT = OFF //Power Up Timer Disabled
#pragma const config BOR = BOHW //Brown Out Reset Enabled in HW, SBOREN disabled
#pragma const config BORV = 20 //Brown Out Voltage : 2.0V
#pragma config WDT = OFF //WATCHDOG HW Disabled - SW Controlled
#pragma config DEBUG = OFF //DEBUG Disabled
#pragma config LVP = OFF //Low Voltage Programming Disabled // Debug off
#define _POT1 RA2
unsigned int Result;
//MAIN
void main(void){
unsigned int duty;
unsigned long U;
void init();
while(1){
//********************ACQUISITIO N potar*************************
ADCON0bits.CHS0=1;ADCON0bits.C HS1=0; ADCON0bits.CHS2=0;ADCON0bits.C HS3=0; // AN1
ADCON0bits.GO_DONE=1;
while(ADCON0bits.GO_DONE==1) // Attente de la fin de conversion
{
}
Result=ADRESL+(ADRESH) ;
U=(long)(Result)*5;
U=U/1023;
duty=Result;
if(duty>243)
{
duty=243;
}
if(duty<13)
{
duty=13;
}
duty=CCPR1L;
}
}
void init(void)
{
PORTA = 255;
TRISA = 0b00001111; //PORTA en tant que sortie, AN0 à AN3 en entrée
PORTB = 0b00000000; // Initialisation du PORTB
PORTC = 0b00000000; // Initialisation du PORTC
TRISC = 0b00000000; //PORTC en tant que sortie
PORTE = 0b00000000;
PORTD = 0b00000000;
//TMR2
T2CONbits.TMR2ON=1;
//prescaler 1
T2CONbits.T2CKPS1=0;
T2CONbits.T2CKPS0=0;
//postscaler 1/16
T2CONbits.TOUTPS0=1;
T2CONbits.TOUTPS1=1;
T2CONbits.TOUTPS2=1;
T2CONbits.TOUTPS3=1;
PR2=0xFF;
//PWM
CCP1CON=0b10010111;
//Aquisition analogique
ADCON2bits.ADFM=1;
ADCON1bits.VCFG=0;
ADCON2bits.ADCS2=0;ADCON2bits. ADCS1=1;ADCON2bits.ADCS2=0;
ADCON0bits.ADON=1;
}
-----