烧到片子里面可以~仿真时如果在定时器中断里面设置一个断点,完了如果按下一下iar软件复位的按钮以后就再以不能中断了~怎么回事?
void AT91F_TC_Open ( AT91PS_TC TC_pt, unsigned int Mode, unsigned int TimerId) //* Begin { unsigned int dummy; //* First, enable the clock of the TIMER AT91F_PMC_EnablePeriphClock ( AT91C_BASE_PMC,1<< TimerId); //* Disable the clock and the interrupts TC_pt->TC_CCR = AT91C_TC_CLKDIS ; TC_pt->TC_IDR = 0xFFFFFFFF ;
//* Clear status bit dummy = TC_pt->TC_SR; //* Suppress warning variable "dummy" was set but never used dummy = dummy; //* Set the Mode of the Timer Counter TC_pt->TC_CMR = Mode ;
//* Enable the clock TC_pt->TC_CCR = AT91C_TC_CLKEN ; //* End }
//*------------------------- Interrupt Function -------------------------------
//*---------------------------------------------------------------------------- //* Function Name : timer0_c_irq_handler //* Object : C handler interrupt function called by the interrupts //* assembling routine //* Output Parameters : increment count_timer0_interrupt //*---------------------------------------------------------------------------- __ramfunc void timer0_c_irq_handler(void) { AT91PS_TC TC_pt = AT91C_BASE_TC0; unsigned int dummy; //* Acknowledge interrupt status dummy = TC_pt->TC_SR; //* Suppress warning variable "dummy" was set but never used dummy = dummy; count_timer0_interrupt++; AT91F_PIO_SetOutput(AT91C_BASE_PIOA,PORTTmp[1]); //恢复最后一次IO口状态 AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,~PORTTmp[1]); R_Status^=BIT0; if (R_Status&BIT0) { AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,BIT7); } else { AT91F_PIO_SetOutput(AT91C_BASE_PIOA,BIT7); } AT91F_PIO_SetOutput(AT91C_BASE_PIOA,LE1); //打开片选 AT91F_PIO_ClearOutput(AT91C_BASE_PIOA,LE1); //关闭片选 PORTTmp[1]=(AT91C_BASE_PIOA->PIO_ODSR&0x000000ff); //保存最后一次锁存后输出口状态
}
//*-------------------------- External Function -------------------------------
//*---------------------------------------------------------------------------- //* Function Name : timer_init //* Object : Init timer counter //* Input Parameters : none //* Output Parameters : TRUE //*---------------------------------------------------------------------------- void timer_init ( void ) //* Begin { //init the timer interrupt counter count_timer0_interrupt=0;
//* Open timer0 AT91F_TC_Open(AT91C_BASE_TC0,TC_CLKS_MCK1024|AT91C_TC_WAVESEL_UP_AUTO|AT91C_TC_WAVE,AT91C_ID_TC0); AT91C_BASE_TC0->TC_RC=46928;
//* Open Timer 0 interrupt AT91F_AIC_ConfigureIt ( AT91C_BASE_AIC, AT91C_ID_TC0, TIMER0_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, timer0_c_irq_handler); AT91C_BASE_TC0->TC_IER = AT91C_TC_CPCS; // IRQ enable CPC AT91F_AIC_EnableIt (AT91C_BASE_AIC, AT91C_ID_TC0); //* Start timer0 AT91C_BASE_TC0->TC_CCR = AT91C_TC_SWTRG ;
//* End }
主频大约48m,中断1s一次~
|