Go Down

Topic: Arduino + AvrStudio => No UART-Actions (using the UART-Library) (Read 1 time) previous topic - next topic

cybergen

Hi there .. i try getting the Arduino-UART to work with AvrStudio .. (for days now) .. and  i doesnt work :(

i am using the UART-Library (supporting atmega328p)
this one ... http://homepage.hispeed.ch/peterfleury/avr-software.html

thats the code:
Code: [Select]
/*************************************************************************
Title:    example program for the Interrupt controlled UART library
Author:   Peter Fleury <pfleury@gmx.ch>   http://jump.to/fleury
File:     $Id: test_uart.c,v 1.4 2005/07/10 11:46:30 Peter Exp $
Software: AVR-GCC 3.3
Hardware: any AVR with built-in UART, tested on AT90S8515 at 4 Mhz

DESCRIPTION:
          This example shows how to use the UART library uart.c

*************************************************************************/
#include <stdlib.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>

#include "uart.h"


/* define CPU frequency in Mhz here if not defined in Makefile */
#ifndef F_CPU
#define F_CPU 16000000UL
#endif

/* 9600 baud */
#define UART_BAUD_RATE      9600     


int main(void)
{
    unsigned int c;
    char buffer[7];
    int  num=134;

    uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
    sei();
    uart_puts("TEST\n");
    for(;;)
    {
        c = uart_getc();
        if ( c & UART_NO_DATA )
        {
            /*
             * no data available from UART
             */
        }
        else
        {
            /*
             * new data available from UART
             * check for Frame or Overrun error
             */
            if ( c & UART_FRAME_ERROR )
            {
                /* Framing Error detected, i.e no stop bit detected */
                uart_puts_P("UART Frame Error: ");
            }
            if ( c & UART_OVERRUN_ERROR )
            {
                /*
                 * Overrun, a character already present in the UART UDR register was
                 * not read by the interrupt handler before the next character arrived,
                 * one or more received characters have been dropped
                 */
                uart_puts_P("UART Overrun Error: ");
            }
            if ( c & UART_BUFFER_OVERFLOW )
            {
                /*
                 * We are not reading the receive buffer fast enough,
                 * one or more received character have been dropped
                 */
                uart_puts_P("Buffer overflow error: ");
            }
            /*
             * send received character back
             */
            uart_putc( (unsigned char)c );
        }
    }
   
}


Build-Result:
Code: [Select]

Build started 28.1.2012 at 12:33:47
avr-gcc  -mmcu=atmega328p -Wall -gdwarf-2 -std=gnu99    -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT uartdemo.o -MF dep/uartdemo.o.d  -c  ../uartdemo.c
../uartdemo.c: In function 'main':
../uartdemo.c:33:10: warning: unused variable 'num'
../uartdemo.c:32:10: warning: unused variable 'buffer'
avr-gcc -mmcu=atmega328p -Wl,-Map=uartdemo.map uartdemo.o uart.o     -o uartdemo.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  uartdemo.elf uartdemo.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex uartdemo.elf uartdemo.eep || exit 0
avr-objdump -h -S uartdemo.elf > uartdemo.lss

AVR Memory Usage
----------------
Device: atmega328p

Program:     700 bytes (2.1% Full)
(.text + .data + .bootloader)

Data:         75 bytes (3.7% Full)
(.data + .bss + .noinit)


Build succeeded with 2 Warnings...


AVR-Duding:
Code: [Select]

C:\avrprj\uart_test\default>\upl uartdemo
Uploading uartdemo.hex ...

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "uartdemo.hex"
avrdude: input file uartdemo.hex auto detected as Intel Hex
avrdude: writing flash (700 bytes):

Writing | ################################################## | 100% 1.56s



avrdude: 700 bytes of flash written
avrdude: verifying flash memory against uartdemo.hex:
avrdude: load data flash data from input file uartdemo.hex:
avrdude: input file uartdemo.hex auto detected as Intel Hex
avrdude: input file uartdemo.hex contains 700 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.17s



avrdude: verifying ...
avrdude: 700 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


C:\avrprj\uart_test\default>


well everything looks fine ... but the uart doesnt work :-\
CPU is set to 16Mhz .. i tested it on Arduino-UNO and Arduino-Duemilanove

Can someone gimme a tip?

Thx Cyb.

cybergen

If i use: http://beaststwo.org/avr-uart/index.shtml ... evertything works :-)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy