uCOS-II and USART1 on SAM7X256

This forum is for users of Atmel's SAM Series and who are interested in using µC/OS-II, The Real-Time Kernel.

Moderator: nferre

Gian78
Posts: 10
Joined: Thu Mar 26, 2009 11:46 am

uCOS-II and USART1 on SAM7X256

Sun Apr 19, 2009 11:27 pm

I have a problem with serial comunication under uCOS-II. My interrupt routine for RX byte on usart1 is continuosly called, but no byte are arriving on the port I checked it with an oscilloscope. When I really receive a byte I read it but the interrupt routine continue to be called and all the time I read the last real caracter I have received!!! I have made an empty project witout uCOS-II and all work fine. I use IAR 5.30

Code: Select all

void BSP_INIT_USART1()
{
    AT91C_BASE_AIC->AIC_IDCR = (1 << AT91C_ID_US1);  
    AT91C_BASE_AIC->AIC_ICCR = (1 << AT91C_ID_US1);   
  
    AT91C_BASE_PIOA->PIO_ASR   = 0x00000360; // Peripheral A Select Register
    
    AT91C_BASE_US1->US_CR   = AT91C_US_RSTRX  |
                              AT91C_US_RSTTX  |
                              AT91C_US_RXDIS  |
                              AT91C_US_TXDIS  |
                              AT91C_US_RSTSTA ;
    
    AT91C_BASE_US1->US_MR   = AT91C_US_USMODE_NORMAL |
                              AT91C_US_CLKS_CLOCK    |
                              AT91C_US_CHRL_8_BITS   |
                              AT91C_US_PAR_NONE      |
                              AT91C_US_NBSTOP_1_BIT  ;
    
    AT91C_BASE_US1->US_BRGR = 0x00000139; // 9600
    
    AT91C_BASE_US1->US_RTOR = 0;
    AT91C_BASE_US1->US_TTGR = 0;
    AT91C_BASE_US1->US_FIDI = 0;
    AT91C_BASE_US1->US_IF   = 0;
    
    AT91C_BASE_AIC->AIC_SVR[AT91C_ID_US1] = (unsigned long)XBEE_RX;
    AT91C_BASE_AIC->AIC_SMR[AT91C_ID_US1] = AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | 4 ;

    AT91C_BASE_US1->US_IDR     = 0xFFFFFFFF;
    AT91C_BASE_US1->US_IER  = (1 << AT91C_US_RXRDY); // Interrupt on RX
    
    AT91C_BASE_US1->US_CR   = AT91C_US_RXEN  |
                              AT91C_US_TXEN;    
    
    // Enable the clock of the PIO
    AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_US1);
}

void BSP_ENABLE_USART1_INT()
{
  AT91C_BASE_AIC->AIC_IECR = (1 << AT91C_ID_US1);  
}
Best regards.
Gian78
Posts: 10
Joined: Thu Mar 26, 2009 11:46 am

Re: uCOS-II and USART1 on SAM7X256

Thu Apr 23, 2009 3:35 pm

Solved, the error was


AT91C_BASE_US1->US_IDR = 0xFFFFFFFF;
AT91C_BASE_US1->US_IER = (1 << AT91C_US_RXRDY); // Interrupt on RX

because

AT91C_US_RXRDY = (1 << 0)

so

1 << (1 << 0)

thath is TX and NOT RX

Return to “- µC/OS-II - Real-Time Kernel”

Who is online

Users browsing this forum: No registered users and 1 guest