|
Hi,
I have a strange issue,
1 .DBGU init below works fine when MCK - 100352000 and PCK -200704000 , pUSART->US_BRGR = 54 2. but for my project I need to set PCK to 133120000 so as MCK 66560000, pUSART->US_BRGR = 36. With these settings characters on hyperterminal are wrong.
DBGU Init code - unsigned int dwMasterClock; AT91PS_USART pUSART = (AT91PS_USART) AT91C_BASE_DBGU; AT91PS_PDC pPDC = (AT91PS_PDC) &(pUSART->US_RPR); AT91PS_PIO pPioB = (AT91PS_PIO) AT91C_BASE_PIOB; dwMasterClock = mck; // // Init the DBGU // // Configure PIO controllers to periph mode pPioB->PIO_ASR = AT91C_PB14_DRXD | AT91C_PB15_DTXD ; pPioB->PIO_PDR = AT91C_PB14_DRXD | AT91C_PB15_DTXD ; //Configure USART // Disable interrupts pUSART->US_IDR = (unsigned int) -1; // Reset receiver and transmitter pUSART->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS ; // Define the baud rate divisor register { unsigned int baud_value = ((dwMasterClock*10)/(baudrate * 16)); if ((baud_value % 10) >= 5) baud_value = (baud_value / 10) + 1; else baud_value /= 10; pUSART->US_BRGR = baud_value; } // Write the Timeguard Register pUSART->US_TTGR = 0; // Clear Transmit and Receive Counters // Disable the RX and TX PDC transfer requests pPDC->PDC_PTCR = AT91C_PDC_RXTDIS; pPDC->PDC_PTCR = AT91C_PDC_TXTDIS; // Reset all Counter register Next buffer first pPDC->PDC_TNPR = 0; pPDC->PDC_TNCR = 0; pPDC->PDC_RPR = 0; pPDC->PDC_RCR = 0; pPDC->PDC_RPR = 0; pPDC->PDC_RCR = 0; pPDC->PDC_TPR = 0; pPDC->PDC_TCR = 0; // Enable the RX and TX PDC transfer requests pPDC->PDC_PTCR = AT91C_PDC_RXTEN; pPDC->PDC_PTCR = AT91C_PDC_TXTEN; // Define the USART mode pUSART->US_MR = AT91C_US_ASYNC_MODE; // Enable Transmitter pUSART->US_CR = AT91C_US_RXEN; pUSART->US_CR = AT91C_US_TXEN;
Any clue to solve the issue will be very helpful. Thanks in advance.
|