We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi. who can help me !! my interrupt occure only one time. I dont know why?? can any body help me why my program dosent work correctly? my startup is SAM7.s
thise is my code:
#include "at91sam7x256.h" #include "lib_at91sam7x256.h" #include "delay.h" void Usart0IrqHandler(void); int main (void) {
int rx; unsigned int rxok; int errorcounter;
*AT91C_PMC_PCER=0xC0000040; //Peripheral Clock Enable *AT91C_PIOA_ASR=0X0000003; *AT91C_PIOA_BSR=0X0000000; *AT91C_PIOA_PDR=0x00000003; //Disable I/O,PA5=RXD0,PA6=TXD0 *AT91C_US0_IDR=0xFFFFFFFF; //ALL OFF USART INTERRUPT DISABLE *AT91C_US0_CR=0x000000AC; //RESET RX & TX *AT91C_US0_BRGR=0x139; //BARD RATE:9600 *AT91C_US0_TTGR=0x00000100; //SET TIME GARD=0
AT91F_PDC_Open(AT91C_BASE_PDC_US0); *AT91C_US0_MR=0X8C0; //8bit,No,1Bit Stop,Asaynchron mode *AT91C_US0_CR=0x50; //ENABLE RX & ENABLE tx *AT91C_US0_IER =0x01; //rxbufer full interrupt is set *AT91C_AIC_IDCR=0x40; //DISABLE THE INTERRUOT ON THE INTERRUPT CONTROLLER AT91C_AIC_SVR[AT91C_ID_US0] = (unsigned int)Usart0IrqHandler; // Set the USART0 IRQ handler address in AIC AT91C_AIC_SMR[AT91C_ID_US0] =(0x00000007); *AT91C_AIC_IECR=0x40; *AT91C_AIC_FFDR=0XFFFFFFFF;
while(1){ *AT91C_US0_CR=0x100; rxok=*AT91C_US0_CSR;
*AT91C_US0_IER =0x4; while(rxok==0x1a1b){ rxok=*AT91C_US0_CSR; delay_ms(10); errorcounter=errorcounter+1; if (errorcounter==100) { *AT91C_US0_CR=0xc; // resettx/resetrx errorcounter=0; } } } return 0; } void Usart0IrqHandler(void){
int rx; int i;
unsigned int rxok; int errorcounter; errorcounter=0; kk=kk+1; rxok=*AT91C_US0_CSR; if (rxok && 0x1){ rx=(*AT91C_US0_RHR & 0xff); *AT91C_US0_THR=kk;//rx&0xff; } else while(rxok==0x1a1b){ rxok=*AT91C_US0_CSR; delay_ms(10); errorcounter=errorcounter+1; if (errorcounter==1000) { *AT91C_US0_CR=0xc; // resettx/resetrx errorcounter=0; } };
*AT91C_US0_CR=0x2100; *AT91C_US0_IDR =0x4; rxok=*AT91C_US0_CSR;
for (i=0; i < 8; i++) { AT91C_BASE_AIC->AIC_EOICR = 0; }
return; }
pleas see my code.I think I do it.if value of it is incorrect pleas say me. in data sheet only say that by wirte in EOICR registery we can set end of the interrupt . but dont say anything about its value!!