| Welcome to AT91SAM Community Forum http://www.at91.com/samphpbb/ |
|
| My usart interrupt occure only one time!! http://www.at91.com/samphpbb/viewtopic.php?f=15&t=18940 |
Page 1 of 1 |
| Author: | Ali Salehi [ Thu Feb 04, 2010 2:06 pm ] |
| Post subject: | My usart interrupt occure only one time!! |
Hi all! how are you ok I have a problem in use keil in at91sam7x256. my usart interrupt occure only one time and i dont know why! can help me about this... very very very very thanks. I use sam7.s for start up and may code is: 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; *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; 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; } 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; *AT91C_AIC_EOICR =0x00; return; } |
|
| Author: | mjbcswitzerland [ Sat Feb 06, 2010 4:16 am ] |
| Post subject: | Re: My usart interrupt occure only one time!! |
Hi Are you sure that you need *AT91C_US0_CR=0x2100; in the interrupt routine? To reset the rx interrupt it is adequate to read the receive holding register. Regards Mark www.uTasker.com |
|
| Author: | Ali Salehi [ Sat Feb 06, 2010 4:20 pm ] |
| Post subject: | Re: My usart interrupt occure only one time!! |
hi.very very thank's for your reply. your advice is right.but I test it! my peroblem is not for it!! are you Don't have any more idea about it? for interrupt mode we should have changing start up file in sam7.s (keil) or we must have other start up? |
|
| Author: | saeed_p61 [ Sat Feb 13, 2010 8:50 pm ] |
| Post subject: | Re: My usart interrupt occure only one time!! |
hello . i have this problem in external intrrupt. the irq is maskd .??!!! |
|
| Author: | Ali Salehi [ Tue Feb 16, 2010 9:56 am ] |
| Post subject: | Re: My usart interrupt occure only one time!! |
hi saeed? I think I find the problem.. the peroblem is for start up file. sam7.s is the basic start up file and for use we should chang it !! but I dont find yet how we can heal it!! |
|
| Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|



Forum