Hallo,

Ik probeer met een atmega 8 en de uart tekst naar hyperterminal te sturen. Maar het lukt mij niet (meer).
Een heel tijdje terug is het mij gelukt, maar nu krijg ik steeds een error van imagecraft als ik hetzelfde programma terug gebruik.

Ik heb volgend programma geschreven, maar dit werkt niet:

# include < iom8v.h >
# include < macros.h >
# include <stdio.h>

char string[15];
//UART0 initialize
// desired baud rate: 9600 // 19200, no parity, 8 data bits 1 stop bit no flow control
// actual: baud rate:9615 (0,2%)
// char size: 8 bit
// parity: Disabled
void uart0_init(void)
{
UCSRB = 0x00; //disable while setting baud rate
UCSRA = 0x00;
UCSRC = BIT(URSEL) | 0x06;
UBRRL = 0x0C; //set baud rate lo
UBRRH = 0x00; //set baud rate hi
UCSRB = 0x18;
}
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
uart0_init();

MCUCR = 0x00;
GICR = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized

}
void main ()
{
init_devices();

printf (" hallo " ) ;

}

Als error krijg ik bij het compileren hetvolgende:
C:\iccv7avr\bin\imakew -f uart.mak
iccavr -c -e -D__ICC_VERSION="7.03A" -DATMega8 -l -g -Wa-IJ:\HOGESC~1\PR03DB~1\atmega\suart -Mavr_enhanced_small -Wa-W J:\HOGESC~1\PR03DB~1\atmega\suart\zigbee-uart.c
iccavr -o uart -g -Wl-W -bfunc_lit:0x26.0x2000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @uart.lk
!ERROR Function 'putchar' not defined. This is a function that references
the device's IO register locations and must be compiled specifically
for the target device. You may find examples of this function for
different devices under the <install root>\examples.AVR directory.
C:\iccv7avr\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1

Waarom wilt de printf functie niet werken?

Alvast bedankt!

Eh... dat staat er toch...
Omdat je geen 'putchar' meelinkt... (hoe moet dat ding anders weten waar de output heen moet?)

Sorry, ben nog nieuw met c programmeren.
Waar/hoe moet ik dan die putchar meelinken?

Met iccavr heb ik geen ervaring. Je kan alleszind proberen


#include <stdlib.h>
#include <string.h>

toe te voegen. Baat het niet, schaden zal het evenmin.

Staat wel ergens in je documentatie neem ik aan. En dit is niet specifiek voor C. Wel voor ene hogere programmeertaal op een uC.
Prototype zal wel iets als

void putchar(const char ch);

ofzo zijn. Neem aan dat je zelf wel kunt verzinnen wat erin moet.

Wat betreft die header files toevoegen: Ik ken die compiler ook niet. Maar het zou op z'n zachst gezegd ranzig zijn als dat je verschijnsel zou onderdrukken...