Академический Документы
Профессиональный Документы
Культура Документы
E C E N 4 4 2 , S p r i n g 2 0 1 5 , H o m e w ork 3
02/18/2015
Due:
void main()
{
// Timer0, ADCINT5, EQEP1_INT Interrupts that are used in this example are
// re-mapped to ISR functions found within this file:
// notice the PieVecTable structure includes the names of the interrupts
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.TINT0 = &cpu_timer0_isr;
PieVectTable.EQEP1_INT = &QEPISRCounterCompare(void);
PieVectTable.ADCINT5 = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
// Enable required interrupts:
// Enable the PIE block
PieCtrlRegs.PIECTRL.bit.ENPIE = 1;
// Enable the interrupts in the PIE level:
// notice the PieCtrlRegs structure includes the order of the interrupts
// within a group: INTx1 INTx2 INTx8
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
PieCtrlRegs.PIEIER10.bit.INTx5 =1;
PieCtrlRegs.PIEIER5.bit.INTx1 = 1;
//Enable the associated groups:
IER |= M_INT1;
IER |= M_INT10;
IER |= M_INT5;
// Enable Global interrupt INTM
EINT;
// Enable Global realtime interrupt DBGM
ERTM;
while(1) {
}
}
//###########################################################################
//
Interrupt Service Routines
//###########################################################################
//The First ISR:
interrupt void cpu_timer0_isr(void)
{
// Acknowledge interrupt to PIE:
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
}