В предыдущем примере были явные ошибки. вот переделал с помощью ненаших форумов. всё равно не то. не заходит. #include "AT91SAM7S256.h"
#include "board.h"
int b=0;
AT91PS_TC pTC =AT91C_BASE_TC0;
AT91PS_AIC pAIC =AT91C_BASE_AIC;
AT91PS_PIO pPIO =AT91C_BASE_PIOA;
AT91PS_CKGR pCKGR=AT91C_BASE_CKGR;
AT91PS_PMC pPMC=AT91C_BASE_PMC;
AT91PS_TCB pTCB = AT91C_BASE_TCB;
void delay(unsigned d)
{
for(;d;d--);
}
__irq void tc_irq_handler(void)
{
if(!b)
{
pPIO->PIO_CODR=LED_MASK;
}
else
pPIO->PIO_SODR=LED_MASK;
b=~b;
delay(100000);
pTC->TC_SR;
AT91C_BASE_AIC->AIC_EOICR = 0;
}
void ConfigureTC ( int milliseconds)
{
AT91C_BASE_PMC->PMC_PCER |= (1 << AT91C_ID_TC0);
pAIC->AIC_IDCR = 1 << AT91C_ID_TC0;
pAIC->AIC_SVR[AT91C_ID_TC0] = (unsigned int) tc_irq_handler;
pAIC->AIC_SMR[AT91C_ID_TC0] = AT91C_AIC_PRIOR_HIGHEST;
pAIC->AIC_ICCR = 1 << AT91C_ID_TC0;
pAIC->AIC_IECR = 1 << AT91C_ID_TC0;
/* SYNC trigger not used */
pTCB->TCB_BCR = 0;
/* external clocks not used */
pTCB->TCB_BMR = 0x15;
/* enable the clock and start it */
pTC->TC_CCR =AT91C_TC_CLKEN|AT91C_TC_SWTRG;
pTC->TC_CMR = AT91C_TC_CLKS_TIMER_DIV5_CLOCK|AT91C_TC_CPCTRG;
pTC->TC_RC = ((MCK / 1024 / 1000) + 1) * milliseconds;
/* enable RC compare interrupt */
pTC->TC_IER = AT91C_TC_CPCS;
/* disable all except RC compare interrupt */
pTC->TC_IDR = 0xEF;
}
int main (void)
{ pPIO->PIO_OER=LED_MASK;
pPIO->PIO_SODR=LED_MASK;
ConfigureTC(1000);
while (1);
}