This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

dose atmel micro hase buge?

I'am working with at91sam7x256 and in my program the usart interrupt dosen't work correctly ! I communicatinon with atmel but it isn't fix yet.

thise is my program...pleas help me

www.4shared.com/.../usart16__2_.html

my mail :salehi.elc@gmail.com

Parents
  • this is our code:

    #include <at91sam7x256.h>
    #include <lib_at91sam7x256.h>
    
    unsigned char test = 48;
    
      void Usart0IrqHandler(void); // function prototype for USART0 handler
    
    volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; // pointer to PMC data structure
    volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
    volatile AT91PS_USART pUsart0 = AT91C_BASE_US0;
    volatile AT91PS_AIC pAIC = AT91C_BASE_AIC; // pointer to AIC data structure
    volatile AT91PS_SYS     pSYS=AT91C_BASE_SYS;
    
    
    
    int main(void){
    
    
              test=70;
    
    
            pPIO->PIO_PDR = (AT91C_PA0_RXD0 | AT91C_PA1_TXD0);
        pPMC->PMC_PCER = (1<<AT91C_ID_US0); // enable usart0 peripheral clock
        pPIO->PIO_ASR = (AT91C_PIO_PA0 | AT91C_PIO_PA1); // define        peripheral A select regidtry
        pPIO->PIO_BSR = 0;
                                      // define      peripheral B select regidtry
    
            pUsart0->US_CR = (AT91C_US_RSTRX | // reset receiver
                          AT91C_US_RSTTX | // reset transmitter
                          AT91C_US_RXDIS | // disable receiver
                          AT91C_US_TXDIS); // disable transmitter
        pUsart0->US_MR = (AT91C_US_PAR_NONE | // no parity
                          0x3 << 6); // 8-bit characters
        pUsart0->US_IER = 0x0000; // no usart0 interrupts enabled (no effect)
            pUsart0->US_IDR = 0xFFFF; // all usart0 interrupts disabled
            pUsart0->US_BRGR = 0x139; // CD = 0x139 (313 from above calculation)
                                  // FP=0 (not used)
        pUsart0->US_RTOR = 0; // receiver time-out (disabled)
        pUsart0->US_TTGR = 0; // transmitter timeguard (disabled)
        pUsart0->US_FIDI = 0; // FI over DI Ratio Value (disabled)
        pUsart0->US_IF = 0; // IrDA Filter value (disabled)
    
             pAIC->AIC_IDCR = (1<<AT91C_ID_US0); // Disable USART0 interrupt in AIC
         pAIC->AIC_SVR[AT91C_ID_US0] = (unsigned int)Usart0IrqHandler; // Set the USART0 IRQ handler address in AIC
         // Source Vector Register[6]
         pAIC->AIC_SMR[AT91C_ID_US0] =(AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 0x4 ); // Set the int source type and pri
         // in AIC Source Mode Register[6]
         pAIC->AIC_IECR = (1<<AT91C_ID_US0); // Enable the USART0 interrupt in AIC
             // enable the USART0 receiver and transmitter
         pUsart0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;
         // enable the USART0 receive interrupt
         pUsart0->US_IER = AT91C_US_RXRDY; // enable RXRDY usart0 receive interrupt
         pUsart0->US_IDR = ~AT91C_US_RXRDY; // disable all other interrupts except RXRDY
    
              test=70;
    
                    do{
                       }while(1);
    
    }
    
    
     void Usart0IrqHandler(void){
    
     int statuse;
                      statuse= pUsart0->US_CSR;
                      test=pUsart0->US_RHR;
    
                        pUsart0->US_THR=test;
                             if (AT91F_US_TxReady(AT91C_BASE_US0)==0)
                                     do{
    
                                     }while(AT91F_US_TxReady(AT91C_BASE_US0)==1);
    
                      AT91C_BASE_AIC->AIC_EOICR = 0;
               return ;
             }
    
    
    
    

Reply
  • this is our code:

    #include <at91sam7x256.h>
    #include <lib_at91sam7x256.h>
    
    unsigned char test = 48;
    
      void Usart0IrqHandler(void); // function prototype for USART0 handler
    
    volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; // pointer to PMC data structure
    volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA;
    volatile AT91PS_USART pUsart0 = AT91C_BASE_US0;
    volatile AT91PS_AIC pAIC = AT91C_BASE_AIC; // pointer to AIC data structure
    volatile AT91PS_SYS     pSYS=AT91C_BASE_SYS;
    
    
    
    int main(void){
    
    
              test=70;
    
    
            pPIO->PIO_PDR = (AT91C_PA0_RXD0 | AT91C_PA1_TXD0);
        pPMC->PMC_PCER = (1<<AT91C_ID_US0); // enable usart0 peripheral clock
        pPIO->PIO_ASR = (AT91C_PIO_PA0 | AT91C_PIO_PA1); // define        peripheral A select regidtry
        pPIO->PIO_BSR = 0;
                                      // define      peripheral B select regidtry
    
            pUsart0->US_CR = (AT91C_US_RSTRX | // reset receiver
                          AT91C_US_RSTTX | // reset transmitter
                          AT91C_US_RXDIS | // disable receiver
                          AT91C_US_TXDIS); // disable transmitter
        pUsart0->US_MR = (AT91C_US_PAR_NONE | // no parity
                          0x3 << 6); // 8-bit characters
        pUsart0->US_IER = 0x0000; // no usart0 interrupts enabled (no effect)
            pUsart0->US_IDR = 0xFFFF; // all usart0 interrupts disabled
            pUsart0->US_BRGR = 0x139; // CD = 0x139 (313 from above calculation)
                                  // FP=0 (not used)
        pUsart0->US_RTOR = 0; // receiver time-out (disabled)
        pUsart0->US_TTGR = 0; // transmitter timeguard (disabled)
        pUsart0->US_FIDI = 0; // FI over DI Ratio Value (disabled)
        pUsart0->US_IF = 0; // IrDA Filter value (disabled)
    
             pAIC->AIC_IDCR = (1<<AT91C_ID_US0); // Disable USART0 interrupt in AIC
         pAIC->AIC_SVR[AT91C_ID_US0] = (unsigned int)Usart0IrqHandler; // Set the USART0 IRQ handler address in AIC
         // Source Vector Register[6]
         pAIC->AIC_SMR[AT91C_ID_US0] =(AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 0x4 ); // Set the int source type and pri
         // in AIC Source Mode Register[6]
         pAIC->AIC_IECR = (1<<AT91C_ID_US0); // Enable the USART0 interrupt in AIC
             // enable the USART0 receiver and transmitter
         pUsart0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;
         // enable the USART0 receive interrupt
         pUsart0->US_IER = AT91C_US_RXRDY; // enable RXRDY usart0 receive interrupt
         pUsart0->US_IDR = ~AT91C_US_RXRDY; // disable all other interrupts except RXRDY
    
              test=70;
    
                    do{
                       }while(1);
    
    }
    
    
     void Usart0IrqHandler(void){
    
     int statuse;
                      statuse= pUsart0->US_CSR;
                      test=pUsart0->US_RHR;
    
                        pUsart0->US_THR=test;
                             if (AT91F_US_TxReady(AT91C_BASE_US0)==0)
                                     do{
    
                                     }while(AT91F_US_TxReady(AT91C_BASE_US0)==1);
    
                      AT91C_BASE_AIC->AIC_EOICR = 0;
               return ;
             }
    
    
    
    

Children