Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USART.h header file does not work #25

Open
naveengautam002 opened this issue Jun 2, 2017 · 9 comments
Open

USART.h header file does not work #25

naveengautam002 opened this issue Jun 2, 2017 · 9 comments

Comments

@naveengautam002
Copy link

/*
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
Copy link

baldowl commented Jun 2, 2017

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

@naveengautam002
Copy link
Author

Page 18 of which?

@adicarlo
Copy link

p 18 of the book, Make: AVR Programming

@skyu74
Copy link

skyu74 commented Oct 27, 2018

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
Copy link

skyu74 commented Oct 27, 2018

Make: AVR Programming

Can you explain in detail?

@skyu74
Copy link

skyu74 commented Oct 27, 2018

Page 18 of which?

Can you explain in detail?

@skyu74
Copy link

skyu74 commented Oct 27, 2018

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

Can you explain in detail?

@hexagon5un
Copy link
Owner

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
Copy link

goalomy commented Nov 2, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants