avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Student Needs Help With ATmega128 Uart Port 1....Seco


From: John Branthoover
Subject: Re: [avr-gcc-list] Student Needs Help With ATmega128 Uart Port 1....Second Attempt.
Date: Wed, 20 Mar 2002 10:08:52 -0800 (PST)

I am BLIND!
  I had looked at this code serval times.  Thank you
very much for pointing out my error.  Have a great
day.

--- dho <address@hidden> wrote:
> Hi John,
> 
> 
>     /* Store received character */
>     UART_RxChar = inp(UDR0);
> here is your bug                      ^   use UDR1
> for UART1
> 
> }
> 
> void UART_SendByte(u08 Data)
> {   
>     /* wait for UART to become available */
>     while(!UART_Ready);
>     UART_Ready = 0;
>     /* Send character */
>     outp( Data, UDR0 );
> see above
> 
> }
> 
> 
> u08 UART_ReceiveByte(void)
> {
>     /* wait for UART to indicate that a character
> has
> been received */
>     while(!UART_ReceivedChar);
>     UART_ReceivedChar = 0;
>     /* read byte from UART data buffer */
>     return UART_RxChar;
> }
> 
> void UART_PrintfProgStr(u08* pBuf)
> {
>     /* wait for UART to become available */
>     while(!UART_Ready);
>     UART_Ready = 0;
>     /* Indicate to ISR the string to be sent */
>     pUART_Buffer = pBuf;
>     /* Send first character */
>     outp( PRG_RDB(pUART_Buffer), UDR1 );
> }
> 
> void UART_PrintfEndOfLine(void)
> {
>     /* wait for UART to become available */
>     while(!UART_Ready);
>     UART_Ready = 0;
>     /* Indicate to ISR the string to be sent */
>     pUART_Buffer = UART_pszEndOfLine;
>     /* Send first character */
>     outp( PRG_RDB(pUART_Buffer), UDR1 );
> }
> 
> void UART_PrintfU4(u08 Data)
> {
>     /* Send 4-bit hex value */
>     u08 Character = Data&0x0f;
>     if (Character>9)
>     {
>         Character+='A'-10;
>     }
>     else
>     {
>         Character+='0';
>     }
>     UART_SendByte(Character);
> }
> 
> void UART_Printfu08(u08 Data)
> {
>     /* Send 8-bit hex value */
>     UART_PrintfU4(Data>>4);
>     UART_PrintfU4(Data   );
> }
> 
> void UART_Printfu16(u16 Data)
> {
>     /* Send 16-bit hex value */
>     UART_PrintfU4(Data>>12);
>     UART_PrintfU4(Data>> 8);
>     UART_PrintfU4(Data>> 4);
>     UART_PrintfU4(Data    );
> }
> 
> void UART_Init(void)
> {
>     UART_Ready        = 1;
>     UART_ReceivedChar = 0;
>     pUART_Buffer      = 0;
>     /* enable RxD/TxD and interrupts */
>    
> outp(BV(RXCIE)|BV(TXCIE)|BV(RXEN)|BV(TXEN),UCSR1B);
>     /* set baud rate */
>     outp(0x0, UBRR1H);
>     outp( (u08)UART_BAUD_SELECT, UBRR1L);  
>     /* enable interrupts */
>     sei();
> }
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - live college hoops coverage
> http://sports.yahoo.com/
> avr-gcc-list at http://avr1.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/
avr-gcc-list at http://avr1.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]