-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
125 lines (89 loc) · 2.49 KB
/
main.c
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
/*
* File: main.c
* Author: 7Robot
*
* Created on 15 septembre 2014, 20:06
*/
//configuration
#pragma config XINST = OFF
//#pragma config FOSC = INTIO2
#include <stdio.h>
#include <stdlib.h>
#include <p18f25k80.h>
#include <xc.h>
#include <timers.h>
#include <p18cxxx.h>
////////////////////////////////////DEFINE /////////////////////////////////
#define SegmentA PORTBbits_t.PORTB7
#define SegmentB PORTBbits_t.PORTB6
#define SegmentC PORTBbits_t.PORTB5
#define SegmentD PORTBbits_t.PORTB4
#define SegmentE PORTBbits_t.PORTB3
#define SegmentF PORTBbits_t.PORTB2
#define SegmentG PORTBbits_t.PORTB1
#define SegmentH PORTBbits_t.PORTB0
#define Afficheur1 PORTAbits_t.RA1
#define Afficheur2 PORTAbits_t.RA2
#define Afficheur3 PORTAbits_t.RA3
#define Afficheur4 PORTAbits_t.RA4
#define Afficheur5 PORTAbits_t.RA5
////////////////////////////////VARIABLES GLOBALES////////////////////////////////////////////
char dixieme_millisecondes = 0;
int millisecondes = 0;
int secondes = 0;
char balayage = 0;
void rafraichissement (int);
//Main Interrupt Service Routine (ISR)
void interrupt low_interrupt()
{
//Check if it is TMR0 Overflow ISR
if(TMR0IE && TMR0IF)
{
//TMR0 Overflow ISR
if (balayage ==4)
{
balayage = 0;
}
else
{
balayage++; //Increment Over Flow Counter
}
rafraichissement(balayage);
//Clear Flag
TMR0IF=0;
}
}
int main(int argc, char** argv) {
///////////////////////CONFIGURATION///////////////////////////////////////////
INTCON = 0b11100000;
TRISB = 0; // mets les ports B en sortie
TRISA = 0; // mets les ports A en sortie
//Setup Timer0 la persistance retinienne
T0PS0=1; //Prescaler is divide by 256
T0PS1=1;
T0PS2=1;
PSA=0; //Timer Clock Source is from Prescaler
T0CS=0; //Prescaler gets clock from FCPU (5MHz)
T08BIT=1; //8 BIT MODE
TMR0IE=1; //Enable TIMER0 Interrupt
PEIE=1; //Enable Peripheral Interrupt
GIE=1; //Enable INTs globally
TMR0ON=1; //Now start the timer!
//setup Timer2
while (1) {
}
return (EXIT_SUCCESS);
}
void rafraichissement (int afficheur)
{
switch(afficheur)
{
case 0 : PORTA =0b00000001; break;
case 1 : PORTA =0b00000010; break;
case 2 : PORTA =0b00000100; break;
case 3 : PORTA =0b00001000; break;
case 4 : PORTA =0b00100000; break;
default : ;
}
}
//intcon tmr4IP IPRX