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  [ 3 posts ] 
Author Message
 Post subject: Problem USART0 configuration YAGARGO AT91SAM9XE-EK(Solved)
PostPosted: Tue Apr 26, 2011 5:27 pm 
Offline

Joined: Tue Apr 26, 2011 5:00 pm
Posts: 4
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
Top
 Profile  
 
 Post subject: Re: Problem USART0 configuration YAGARGO GCC AT91SAM9XE-EK
PostPosted: Tue Apr 26, 2011 6:41 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
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.


Top
 Profile  
 
 Post subject: Re: Problem USART0 configuration YAGARGO AT91SAM9XE-EK(Solved)
PostPosted: Tue Apr 26, 2011 7:59 pm 
Offline

Joined: Tue Apr 26, 2011 5:00 pm
Posts: 4
THanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11 :D

GRacias

Saludos Cordiales



Best Regards


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 1 guest


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: