Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: My usart interrupt occure only one time!!
PostPosted: Thu Feb 04, 2010 2:06 pm 
Offline

Joined: Thu Feb 04, 2010 1:56 pm
Posts: 3
Hi all! how are you :D ?
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;
}


Top
 Profile  
 
 Post subject: Re: My usart interrupt occure only one time!!
PostPosted: Sat Feb 06, 2010 4:16 am 
Offline

Joined: Thu Mar 02, 2006 1:32 pm
Posts: 127
Location: Switzerland
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


Top
 Profile  
 
 Post subject: Re: My usart interrupt occure only one time!!
PostPosted: Sat Feb 06, 2010 4:20 pm 
Offline

Joined: Thu Feb 04, 2010 1:56 pm
Posts: 3
hi.very very thank's for your reply.

your advice is right.but I test it! my peroblem is not for it!! :( :cry:

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?


Top
 Profile  
 
 Post subject: Re: My usart interrupt occure only one time!!
PostPosted: Sat Feb 13, 2010 8:50 pm 
Offline

Joined: Sat Feb 13, 2010 12:06 pm
Posts: 8
hello .
i have this problem in external intrrupt.
the irq is maskd .??!!!


Top
 Profile  
 
 Post subject: Re: My usart interrupt occure only one time!!
PostPosted: Tue Feb 16, 2010 9:56 am 
Offline

Joined: Thu Feb 04, 2010 1:56 pm
Posts: 3
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!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: