Salut,

toujours dans le soucie de maîtriser ce micro, et après avoir réussi à comprendre certaines notions comme le temps pour pouvoir faire des tempos avec les timers, l'utilisation d'i/O en mode pull-up pour activer des entrées et avoir mis en place tant bien que mal des interruptions qui vont bien pour faire fonctionner tout ça, j'éprouve encore quelques difficultés sur les notions d'interruption et de priorités, notamment en ce qui concerne mon compilateur au niveau des i/O qui ne sont pas configurable en pull-up.

j'ai donc d'autres entrées que j'active par un plus vcc et rien ne ce passe pour l'instant, j'ai galéré toutes la journée pour les activé mais je ne comprend pas ce qui ne va pas.

Auriez vous une suggestion qui me feront avancer
Merci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/*********************************************************************
 *
 *      PIC32MX 
 *
 *********************************************************************
 *
 * FileName:        main.c
 *
 * Dependencies:    plib.h
 *
 * Processor:       PIC32MX
 *
 * Complier:        MPLAB C32
 *                  MPLAB IDE
 *
 * Company:        
 *
 * auteur:                      
 *
 *********************************************************************/
#include <plib.h>
 
#include "fonction.h"
#define extern
#include "definition.h"
#undef extern
 
 
 
#if defined (__32MX360F512L__) || (__32MX460F512L__) || (__32MX795F512L__) || (__32MX430F064L__)
 
//					clock X20  ,	clock /2	 ,	clock/?		   ,Validation du wathdog	
#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = ON
//		Mode oscillateur int,  pas de PLL,	FPB/1
#pragma config POSCMOD = OFF, FNOSC = FRC, FPBDIV = DIV_1
 
#endif
 
//struct input BP;
 
 
 
 
void init_port(void)
{
    // Clear PORT bits so there are no unexpected flashes when setting
    // them to output in the next step
    mPORTDClearBits(BIT_2 |BIT_1 | BIT_0);
	mPORTDClearBits(BIT_6 |BIT_7 | BIT_13);
	mPORTBClearBits(BIT_8|BIT_9 |BIT_10 | BIT_11|BIT_13|BIT_14 |BIT_15);
	mPORTAClearBits(BIT_1);
 
	// PORT as input analogique
	PORTSetPinsAnalogIn(IOPORT_B, BIT_3 | BIT_2| BIT_1| BIT_0);
 
    // PORT as output digital
    mPORTDSetPinsDigitalOut(BIT_2 |BIT_1 | BIT_0);
	mPORTBSetPinsDigitalOut(BIT_8|BIT_9 |BIT_10 | BIT_11);
 
	// PORT as input digital
	mPORTDSetPinsDigitalIn(BIT_6|BIT_7 |BIT_13);
	mPORTBSetPinsDigitalIn(BIT_13|BIT_14 |BIT_15);
	mPORTASetPinsDigitalIn(BIT_1);
 
 
 
}
 
void init_timer1(void)
{
	// Configure Timer 1 using PBCLK as input, 1:256 prescaler
    // Period matches the Timer 1 frequency, so the interrupt handler
    // will trigger every one second...
 
	//OpenTimer1(T1_ON | T1_SOURCE_INT | T1_PS_1_1, PERIOD);
	T1CONbits.ON=1;	   //enable clock timer1
	T1CONbits.TCS=0;   //internal clock
	//T1CONbits.TCKPS=0; //Prescalaire 1:1
	T1CONbits.TCKPS=1; //Prescalaire 1:8
	//T1CONbits.TCKPS=2; //Prescalaire 1:64
	//T1CONbits.TCKPS=3; //Prescalaire 1:256
	WriteTimer1(COMPTAGE);
	INTClearFlag(INT_T1);
 
 
 
    // Set up the timer interrupt
    //INTEnable(INT_T1, INT_ENABLED);
 
	ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
 
 
	//priority of 2
    //INTSetVectorPriority(INT_TIMER_1_VECTOR, INT_PRIORITY_LEVEL_2);
    //INTSetVectorSubPriority(INT_TIMER_1_VECTOR, INT_SUB_PRIORITY_LEVEL_0);
 
	    // set up the core timer interrupt with a prioirty of 2 and zero sub-priority
    //mConfigIntCoreTimer((CT_INT_ON | CT_INT_PRIOR_2 | CT_INT_SUB_PRIOR_0));
}
 
 
 
/**********************************************************************************************
*
*                       Interruption 
*
*
***********************************************************************************************/
 
// Configure the Timer 1 interrupt handler
void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
{
 
    	// Clear the interrupt flag
    	INTClearFlag(INT_T1);
		ms++;
 
 
		WriteTimer1(COMPTAGE);
 
}
 
 
 
// Configure l'interruption des entrées pullup
void __ISR(_CHANGE_NOTICE_VECTOR, ipl3) ChangeNotice_Handler(void)
{
    // Step #1 - always clear the mismatch condition first
     mCNClearIntFlag();
//	ms=0;
 
if (mPORTDReadBits(BIT_6)==0) sw=1;
if (mPORTDReadBits(BIT_7)==0) sw=2;
if (mPORTDReadBits(BIT_13)==0) sw=3;
if (mPORTBReadBits(BIT_15)==0) sw=0;
//if (mPORTBReadBits(BIT_15)==0) sw=0;
//sw=mPORTBReadBits(BIT_13);
//sw=mPORTBReadBits(BIT_14);
//sw=mPORTBReadBits(BIT_15);
//sw=mPORTAReadBits(BIT_0);
    // Step #2 - then clear the interrupt flag
 
 
 
 
 }
 
 
void __ISR(_EXTERNAL_0_VECTOR,ipl4) INT1Handler()
{
 
	INTClearFlag(INT_INT0);
if (mPORTBReadBits(BIT_13)==1) sw=3;
if (mPORTBReadBits(BIT_14)==1) sw=3;
if (mPORTAReadBits(BIT_1)==1) sw=3;
} 
 
//*************************************************************************************************
 
 
void init_variable(void)
{
 
ms=0;
sw=0;
 
}
 
 
 
 
void clignotement(void)
{
 
 
	switch(sw)
	{
 
		case 0 : 		while (ms>=ONE_SECOND)
						{
  						// Toggle LEDs on the Explorer-16
  						mPORTDToggleBits(BIT_2 | BIT_1 | BIT_0);
						mPORTBToggleBits(BIT_8|BIT_9 |BIT_10 | BIT_11);
						ms=0;
						}
						//goto SELECT;
						break;
 
		case 1 :	 	while(ms>=DEMI_SECOND)
						{
  						// Toggle LEDs on the Explorer-16
  						mPORTDToggleBits(BIT_2 | BIT_1 | BIT_0);
						mPORTBToggleBits(BIT_8|BIT_9 |BIT_10 | BIT_11);
						ms=0;
						}
						//goto SELECT;
						break;
		case 2 :	 	while(ms>=CENTMS_SECOND)
						{
  						// Toggle LEDs on the Explorer-16
  						mPORTDToggleBits(BIT_2 | BIT_1 | BIT_0);
						mPORTBToggleBits(BIT_8|BIT_9 |BIT_10 | BIT_11);
						ms=0;
						}
						//goto SELECT;
						break;
		case 3 :	 	while(ms>=CINQMS_SECOND)
						{
  						// Toggle LEDs on the Explorer-16
  						mPORTDToggleBits(BIT_2 | BIT_1 | BIT_0);
						mPORTBToggleBits(BIT_8|BIT_9 |BIT_10 | BIT_11);
						ms=0;
						}
						//goto SELECT;
						break;
 
 
 
	//SELECT:ClearWDT();
	ClearWDT();
	}
 
}
 
 
void bp(void)
{
 
 
 
if (mPORTBReadBits(BIT_13)==1) sw=3;
if (mPORTBReadBits(BIT_14)==1) sw=3;
if (mPORTAReadBits(BIT_1)==1) sw=3;
 
ClearWDT();
}
 
 
 
 
 
int main(void)
{
 
 
 
 
	// Enable change notice, enable discrete pins and weak pullups
    mCNOpen(CONFIG, PINS, PULLUPS);
	EnableINT0;
	// Clear change notice interrupt flag
    ConfigIntCN(INTERRUPT);
	ConfigINT0(EXT_INT_ENABLE|RISING_EDGE_INT|EXT_INT_PRI_3 );
 
	//Enable multi-vector interrupts
    INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
    INTEnableInterrupts();
    // enable device multi-vector interrupts
    INTEnableSystemMultiVectoredInt();//ClrWdt();
 
	//init_intport();
	init_timer1();
	init_port();
	init_variable();//ClrWdt();
	//PORTSetPinsDigitalOut(IOPORT_D,BIT_3);
 
 
 		while (1)
		{
		ClearWDT();
		bp();
		clignotement();
		ClearWDT();
		}
 
 
return 0;
}