Atmel website | ARM Community | AVR freaks | Technical Support
Banner
Welcome to AT91SAM Community Forum
http://www.at91.com/samphpbb/

Problem USART0 configuration YAGARGO AT91SAM9XE-EK(Solved)
http://www.at91.com/samphpbb/viewtopic.php?f=9&t=20079
Page 1 of 1

Author:  Slaxtrack [ Tue Apr 26, 2011 5:27 pm ]
Post subject:  Problem USART0 configuration YAGARGO AT91SAM9XE-EK(Solved)

I have the kit AT91SAM9XE-EK evaluation had never program on this platform

Example configuration DBGUID-USART (Works) (GCC YAGARTO)


DBGU_Configure void (unsigned int mode,
unsigned int baudrate,
unsigned int mck)
{
/ / Reset receiver and transmitter & disable, disable interrupts
AT91C_BASE_DBGU-> DBGU_CR = AT91C_US_RSTRX | AT91C_US_RSTTX;
AT91C_BASE_DBGU-> DBGU_IDR = 0xFFFFFFFF;

/ / Set baud rate
AT91C_BASE_DBGU-> DBGU_BRGR = mck / (baudrate * 16);

/ / Set mode register
AT91C_BASE_DBGU-> DBGU_MR = mode;

/ / Disable DMA channel
AT91C_BASE_DBGU-> DBGU_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;

/ / Enable receiver and transmitter
AT91C_BASE_DBGU-> DBGU_CR = AT91C_US_RXEN | AT91C_US_TXEN;
}


///////////////////////////////////////////////////////77




I want to set the USART0 but my code does not work ....guys i need your help ...

I need to set the pio?
(MY CODE)


fOR EXAMPLE/////////

# Define BOARD_MCK ((18432000 * 97 / 9) / 2)

void main ()
{
USART0_Configure (AT91C_US_PAR_NONE, 115200, BOARD_MCK)
USART0_PutChar ('S'); USART0_PutChar ('o'); USART0_PutChar ('S');

}


////////////////////////////////////////////////// ///////////////////////////
USART0_Configure void (unsigned int mode,
unsigned int baudrate,
unsigned int mck)
{

AT91C_BASE_US0-> US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX;
AT91C_BASE_US0-> US_IDR = 0xFFFFFFFF;
AT91C_BASE_US0-> US_BRGR = mck / (baudrate * 16);

AT91C_BASE_US0-> US_MR = mode;

AT91C_BASE_US0-> US_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;
AT91C_BASE_US0-> US_CR = AT91C_US_RXEN | AT91C_US_TXEN;
}

static void USART0_PutChar (unsigned char c)
{
/ / Wait for the transmitter to Be Ready

while ((AT91C_BASE_US0-> US_CSR & AT91C_US_TXEMPTY) == 0);
AT91C_BASE_US0-> US_THR = c;
while ((AT91C_BASE_US0-> US_CSR & AT91C_US_TXEMPTY) == 0);
}
////////////////////////////////////////////////// //////////////////

Fix Problem

For example USART0

const Pin at91board_usart[] = {PIN_USART0_RXD, PIN_USART0_TXD};

int main()
{
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_US0);
PIO_Configure(at91board_usart, PIO_LISTSIZE(at91board_usart));
USART_Configure(AT91C_BASE_US0,USART_MODE_ASYNCHRONOUS,19200,BOARD_MCK);
USART_SetReceiverEnabled(AT91C_BASE_US0,1);
USART_SetTransmitterEnabled(AT91C_BASE_US0,1);
.
.
.
}


All features are found in the attached file !!!

Attachments:
File comment: All features are found in the attached file
usart.rar [4.01 KiB]
Downloaded 10 times

Author:  CptTitanic [ Tue Apr 26, 2011 6:41 pm ]
Post subject:  Re: Problem USART0 configuration YAGARGO GCC AT91SAM9XE-EK

Something along the lines of the following.

/// USART0 TXD pin definition.
#define PIN_USART0_TXD {1 << 4, AT91C_BASE_PIOB, AT91C_ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
/// USART0 RXD pin definition.
#define PIN_USART0_RXD {1 << 5, AT91C_BASE_PIOB, AT91C_ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
/// USART0 RTS pin definition.
#define PIN_USART0_RTS {1 << 26, AT91C_BASE_PIOB, AT91C_ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
/// USART0 CTS pin definition.
#define PIN_USART0_CTS {1 << 27, AT91C_BASE_PIOB, AT91C_ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT}
/// USART0 SCK pin definition.
#define PIN_USART0_SCK {1 << 31, AT91C_BASE_PIOA, AT91C_ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}

Using the AT91Lib,

// Define the pins you want to be using
const Pin pPins[] = {PIN_USART0_TXD, PIN_USART0_RXD};

// Enable peripheral clock PIOA, in case you forgot
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA;

// Enable pins
PIO_Configure(pPins, PIO_LISTSIZE(pPins));

// Enable peripheral clock USART0
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_US0;

//Now your USART initialization code.

Author:  Slaxtrack [ Tue Apr 26, 2011 7:59 pm ]
Post subject:  Re: Problem USART0 configuration YAGARGO AT91SAM9XE-EK(Solved)

THanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11 :D

GRacias

Saludos Cordiales



Best Regards

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/