hexagon5un / AVR-Programming

Code examples for the book "Make: AVR Programming"
http://littlehacks.org/AVR-Programming
MIT License
744 stars 340 forks source link

USART.h header file does not work #25

Open naveengautam002 opened 7 years ago

naveengautam002 commented 7 years ago

/ 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.

baldowl commented 7 years ago

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

naveengautam002 commented 7 years ago

Page 18 of which?

adicarlo commented 7 years ago

p 18 of the book, Make: AVR Programming

skyu74 commented 5 years ago

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 commented 5 years ago

Make: AVR Programming

Can you explain in detail?

skyu74 commented 5 years ago

Page 18 of which?

Can you explain in detail?

skyu74 commented 5 years ago

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

Can you explain in detail?

hexagon5un commented 5 years ago

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.

goalomy commented 3 years ago

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