Bonjour à vous tous,
j'ai réalisé ce programme pour un PIC16F505 et celui-ci ne fonctionne pas.
La première opération qu'il doit faire est de lancer le buzzer.
Mais rien ne se passe.
Je souhaiterai savoir si jei n'ai pas fais une erreur de configuration dans cette partie de programme.
En 2 mots, est-ce que mon PIC est bien configuré?
Merci à tous ceux qui voudront bien jeter un coup d'oeil.
Michel5002
Voici la partie du programme en question:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// Standard Header file for the PIC16F505 device ////////////////
#device PIC16F505
#nolist
//////// Program memory: 1024x12 Data RAM: 72 Stack: 2
//////// I/O: 12 Analog Pins: 0
//////// C Scratch area: 08 ID Location: 0400
//////// Oscilator Calibration Address: 05
//////// Fuses: LP,XT,HS,EC_IO,NOWDT,WDT,PROTE CT,NOPROTECT,NOMCLR,MCLR,RC
//////// Fuses: INTRC_IO,INTRC,RC_IO
////////
////////////////////////////////////////////////////////////////// I/O
// Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(),
// PORT_x_PULLUPS(), INPUT(),
// OUTPUT_LOW(), OUTPUT_HIGH(),
// OUTPUT_FLOAT(), OUTPUT_BIT()
// Constants used to identify pins in the above are:
#define PIN_B0 48
#define PIN_B1 49
#define PIN_B2 50
#define PIN_B3 51
#define PIN_B4 52
#define PIN_B5 53
#define PIN_C0 56
#define PIN_C1 57
#define PIN_C2 58
#define PIN_C3 59
#define PIN_C4 60
#define PIN_C5 61
////////////////////////////////////////////////////////////////// Useful defines
#define FALSE 0
#define TRUE 1
#define BYTE int8
#define BOOLEAN int1
#define getc getch
#define fgetc getch
#define getchar getch
#define putc putchar
#define fputc putchar
#define fgets gets
#define fputs puts
////////////////////////////////////////////////////////////////// Control
// Control Functions: RESET_CPU(), SLEEP(), RESTART_CAUSE()
// Constants returned from RESTART_CAUSE() are:
#define WDT_FROM_SLEEP 3
#define WDT_TIMEOUT 11
#define MCLR_FROM_SLEEP 19
#define MCLR_FROM_RUN 27
#define NORMAL_POWER_UP 25
#define BROWNOUT_RESTART 26
////////////////////////////////////////////////////////////////// Timer 0
// Timer 0 (AKA RTCC)Functions: SETUP_COUNTERS() or SETUP_TIMER_0(),
// SET_TIMER0() or SET_RTCC(),
// GET_TIMER0() or GET_RTCC()
// Constants used for SETUP_TIMER_0() are:
#define RTCC_INTERNAL 0
#define RTCC_EXT_L_TO_H 32
#define RTCC_EXT_H_TO_L 48
#define RTCC_DIV_1 8
#define RTCC_DIV_2 0
#define RTCC_DIV_4 1
#define RTCC_DIV_8 2
#define RTCC_DIV_16 3
#define RTCC_DIV_32 4
#define RTCC_DIV_64 5
#define RTCC_DIV_128 6
#define RTCC_DIV_256 7
#define RTCC_8_BIT 0
// Constants used for SETUP_COUNTERS() are the above
// constants for the 1st param and the following for
// the 2nd param:
////////////////////////////////////////////////////////////////// WDT
// Watch Dog Timer Functions: SETUP_WDT() or SETUP_COUNTERS() (see above)
// RESTART_WDT()
// WDT base is 18ms
//
#define WDT_18MS 0x8008
#define WDT_36MS 9
#define WDT_72MS 10
#define WDT_144MS 11
#define WDT_288MS 12
#define WDT_576MS 13
#define WDT_1152MS 14
#define WDT_2304MS 15
//#define DISABLE_PULLUPS 0x40 // for 508 and 509 only
//#define DISABLE_WAKEUP_ON_CHANGE 0x80 // for 508 and 509 only
//#ifndef PIN_CHANGE_FROM_SLEEP
//#define PIN_CHANGE_FROM_SLEEP 0x90 // for 508 and 509 only
//#endif
#list
#device adc=8
#use delay(clock=4000000)
#fuses WDT,NOPROTECT,NOMCLR,INTRC_IO
#define RB0 PIN_B0
#define RB1 PIN_B1
#define RB2 PIN_B2
#define RC0 PIN_C0
#define RC1 PIN_C1
#define RC2 PIN_C2
#define RC3 PIN_C3
#define RC4 PIN_C4
#define RC5 PIN_C5
#define RB3 PIN_B3
#define RB4 PIN_B4
#define RB5 PIN_B5
#use fast_io(B)
#use fast_io(C)
#BYTE TRISB = 0x85
#BYTE TRISC = 0x87
//#BYTE WPUB = 0x95 // Résistances internes PORTB
//#BYTE WPUC = 0x95 // Résistances internes PORTC
//#BYTE OSCTUNE = 0x90
void bips_boucle_ouverte(void);
void enclenchement_relais_sirene(vo id);
void bip_apres_alarme(void);
byte depart=0;
byte duree=0;
byte attente_bip_sortie=5; // 15=30sec
byte attente_bip_entree=5; // 15=30sec
byte memoire_alarme=0;
byte controle=1;
byte attente_bip_boucle_ouverte=30; // 400=15min
void main()
{
debut:
if (memoire_alarme==0)
{
output_low (RC3);
memoire_alarme=1;
}
if (memoire_alarme==1)
{
TRISB=0x04; // 04=00000100 = RB2 en input
TRISC=0x10; // 10=00010000 = RC4 en input
// WPUB=0x00; // 30=00110000
// WPUC=0x00; // 24=00100100
// OSCTUNE=0x06; // BINAIRE=110 ===> 4Mz voir datasheet
output_low (RB0);
output_low (RB1);
output_low (RB2);
output_low (RC0);
output_low (RB5);
setup_wdt(WDT_2304MS);
output_high(RB4);
output_high(RC5);
}
if (depart==0)
{
if (attente_bip_sortie>0)
{
output_high (PIN_C2);//(RC2); // actionne le buzzer
attente_bip_sortie-=1;
}
if (attente_bip_sortie==0)
{
output_low (RC2); // arrête le buzzer
depart=1;
}
}
etc....
-----