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
| /*********************************************************************
*
* 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__)
#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_1, FPLLODIV = DIV_1, FWDTEN = ON
#pragma config POSCMOD = OFF, FNOSC = FRCPLL, FPBDIV = DIV_1
#endif
void init_port(void)
{
// Clear PORTA bits so there are no unexpected flashes when setting
// them to output in the next step
mPORTDClearBits(BIT_2 |BIT_1 | BIT_0);
mPORTBClearBits(BIT_8|BIT_9 |BIT_10 | BIT_11);
// Make lower four bits of PORTD as output
mPORTDSetPinsDigitalOut(BIT_3 |BIT_2 |BIT_1 | BIT_0);
mPORTBSetPinsDigitalOut(BIT_8|BIT_9 |BIT_10 | BIT_11);
}
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
INTClearFlag(INT_T1);
// Set up the timer interrupt
//INTEnable(INT_T1, INT_ENABLED);
ConfigIntTimer1(T1_INT_ON | T1_INT_PRIOR_2);
}
// Configure the Timer 1 interrupt handler
void __ISR(_TIMER_1_VECTOR, ipl2) Timer1Handler(void)
{
// Clear the interrupt flag
INTClearFlag(INT_T1);
mPORTDToggleBits(BIT_2 | BIT_1 | BIT_0);
mPORTBToggleBits(BIT_8|BIT_9 |BIT_10 | BIT_11);
}
int main(void)
{
// Enable multi-vector interrupts
INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
INTEnableInterrupts();
INTEnableSystemMultiVectoredInt();//ClrWdt();
init_timer1();
init_port();
init_variable();//ClrWdt();
//PORTSetPinsDigitalOut(IOPORT_D,BIT_3);
while (1)
{
}
return 0;
} |
Partager