Hi. my usart interrupt dont work correctly .when I chek it in the debugger the US_CR value from 0x1A1A chang to the 0x1A1B and after that the usart hang up!!
in other place in debugger when I chek ofter every interrupt the program doese reset! and I dont know why!!
I think hang up is for a lot of reset of program when a lot of interrupt occure.
It's very funny that if I say that if I deletion the
delay_ms(100);
in my program my Interrupt only work one time! not reset and not anything else! but only work one time and in secend time the interrupt occure the US_CR from 0x1A1A chang to 0x1A1B it's mean that the Rx ready bit in US_CR from 0 becom to 1! OOOK. pleas Help me .but If dont help me I hang up too!like my micro!
my start up is sam7.s are you think my problem is that I dont use another start up file .or i must chang it !!!
and thise is my code:
#include "at91sam7x256.h" #include "lib_at91sam7x256.h" #include "delay.h" void Usart0IrqHandler(void); int kk=70; int main (void) { volatile AT91PS_USART pUSART0 = AT91C_BASE_US0; 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; delay_ms(100); *AT91C_US0_IER =0x4; } return 0; } void Usart0IrqHandler(void){ int rx; int i; volatile AT91PS_AIC pAIC = AT91C_BASE_AIC; 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; } *AT91C_US0_CR=0x2100; *AT91C_US0_IDR =0x4; rxok=*AT91C_US0_CSR; *AT91C_AIC_EOICR =0x00; //end point of interrupt return; }
I set ox00 value in AIC_EOICR registry.It's right or or the problem is for it? thank's
Hi man..I think if you help to solve peroblems is better to find plagiarism in thise site. ok?