1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
//#include "A_define_hard.h"
#include "A_actions.h"
#include "A_test.h"
#include "D_afficheur_segment.h"
#include "D_bouton.h"
#include "D_UART.h"
#include "D_bouton_re.h"
#include "D_afficheur_segment_re.h"
#include "FSIO.h"
#include "p18f46k20.h"
//registre de configuration du micro PIC18F46K20
#pragma config FOSC = INTIO67 //Internal oscillator block, port function on RA6 and RA7
#pragma config PWRT = ON
#pragma config MCLRE = ON
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config BOREN = SBORDIS
#pragma config BORV = 30
#pragma config WDTEN = ON //autorisation du WDT
#pragma config WDTPS = 256 //1/31khz * 128 * 256 = 1s
#pragma config PBADEN = OFF
#pragma config STVREN = ON
#pragma config DEBUG = OFF
#pragma config LVP = OFF
#pragma config HFOFST = OFF
#pragma config LPT1OSC = OFF
#pragma config XINST = OFF
#pragma romdata mydata_scn=0xf00100
#pragma romdata
/* Déclaration des variables utilisables ************************************************************************************/
unsigned char UCH_flag_it_10ms;
unsigned char UCH_cpt_10ms;
/* Déclaration de fonctions utilisatbles ************************************************************************************/
void F_init_hard(void);
/********************Programme Principal ************************************************************************************/
int main ( int argc, char* argv)
{
//void F_lecture_num_bouton(void);
F_init_hard();
//init variable de gestion des tâches
UCH_flag_it_10ms = 0;
UCH_cpt_10ms = 0;
//F_init_appli();
while(1)
{
ClrWdt();
if(UCH_flag_it_10ms)
{
UCH_flag_it_10ms--;
//F_action_10ms(); //tâche 10ms
if(++UCH_cpt_10ms>10)
{
UCH_cpt_10ms-=10;
// F_action_100ms(); //tâche 100ms
}
}
//F_action_de_fond(); //tâche de fond
}
}
/* Implémentation des fonctions ************************************************************************************/
/**************************************************************************************************************************
* fonction : F_init_hard
*------------------------------------------------------------------------------------------------------------------------
* description : Cette fonction permet d'initialiser les interfaces matériels du micro.
*
* entrée : aucun
* sortie : aucun
****************************************************************************************************************************/
void F_init_hard(void)
{
//paramétrage OSC interne 16MHz avec PLL * 4 ==> 64 MHz.
OSCCONbits.IRCF0 = 1;
OSCCONbits.IRCF1 = 1;
OSCCONbits.IRCF2 = 1;
OSCTUNEbits.PLLEN = 1;
OSCTUNEbits.INTSRC = 0;
//port I/O DIGITAL
ANSEL = 0;
ANSELH = 0;
//INIT PORT BOUTON
TRISAbits.TRISA5 = 1; //B_TST en entrée
TRISAbits.TRISA6 = 1; //B_VOL en entrée
TRISAbits.TRISA7 = 1; //B_MEL en entrée
//INIT PORT AFFICHEUR
TRISAbits.TRISA0 = 0; //SEGCLK en sortie
TRISAbits.TRISA1 = 0; //SEGDAT en sortie
TRISCbits.TRISC2 = 0; //OSEG en sortie
//INIT TIMER1 10ms
INIT_TIMER1_500NS;
INIT_TIMER1;
//AUTORISE IT TIMER1
PIR1bits.TMR1IF = 0;
PIE1bits.TMR1IE = 1;
//AUTORISE IT GENERAL
ENABLE_IT_PE;
ENABLE_IT;
//INIT PORT SD**********by guigueek
TRISCbits.TRISC0 = 0; //CHIP SELECT SD en sortie
TRISCbits.TRISC3 = 0; //Clock SD en sortie
TRISCbits.TRISC4 = 1; //Sortie SD en entrée
TRISCbits.TRISC5 = 0; //Entrée SD en sortie
} |