AVR-Programming icon indicating copy to clipboard operation
AVR-Programming copied to clipboard

USART.h header file does not work

Open naveengautam002 opened this issue 7 years ago • 9 comments

/* A simple test of serial-port functionality. Takes in a character at a time and sends it right back out, displaying the ASCII value on the LEDs. */

// ------- Preamble -------- // #define F_CPU 12000000UL #include <avr/io.h> #include <util/delay.h> #include "pinDefines.h" #include "USART.h"

int main(void) { char serialCharacter;

// -------- Inits --------- // LED_DDR = 0xff; /* set up LEDs for output / initUSART(); printString("Hello World!\r\n"); / to test */

// ------ Event loop ------ // while (1) {

serialCharacter = receiveByte();
transmitByte(serialCharacter);
LED_PORT = serialCharacter;
                       /* display ascii/numeric value of character */

} /* End event loop */ return 0; }


ERRORS

error "recipe for target 'USART.o' failed " error "F_CPU must be a constant value" error "setbaud.h requires F_CPU to be defined" #warning "UBRR value overflow" [-Wcpp] error "F_CPU' undeclared (first use in this function)" each undeclared identifier is reported only once for each function it appears in Severity Code Description Project File Line Error "recipe for target 'USART.o' failed"


using ATMEL STUDIO 7.0.

naveengautam002 avatar Jun 02 '17 09:06 naveengautam002

See note on page 18 about Atmel Studio and the need to define F_CPU and BAUD at the project level.

baldowl avatar Jun 02 '17 16:06 baldowl

Page 18 of which?

naveengautam002 avatar Jun 03 '17 15:06 naveengautam002

p 18 of the book, Make: AVR Programming

adicarlo avatar Aug 13 '17 02:08 adicarlo

The following error occurs. Is there a way around this?

#error "setbaud.h requires F_CPU to be defined" #errot "F_CPU must e a constant value" #warning "UBRR value overflow" [-Wcpp]

skyu74 avatar Oct 27 '18 13:10 skyu74

Make: AVR Programming

Can you explain in detail?

skyu74 avatar Oct 27 '18 13:10 skyu74

Page 18 of which?

Can you explain in detail?

skyu74 avatar Oct 27 '18 13:10 skyu74

Atmel Studio에 대한 18 페이지의 설명 F_CPUBAUD프로젝트 레벨에서 정의해야 할 필요성에 대해 알아보십시오 .

Can you explain in detail?

skyu74 avatar Oct 27 '18 13:10 skyu74

The code sets FCPU = 12 MHz. (What?) But then you're using Studio, which maybe ignores this value anyway.

I have not kept up with Studio in the last few (5?) years, so I'm unable to help there, but the error really looks like you're not defining FCPU on the right page in the project's settings.

hexagon5un avatar Nov 13 '18 14:11 hexagon5un

hey @naveengautam002 first of all remove F_CPU 12000000UL from your main code and #define F_CPU 1000000 UL in USART.c. here is pic for your reference WhatsApp Image 2020-11-03 at 00 35 32

goalomy avatar Nov 02 '20 19:11 goalomy