program compiles when i include .c file but doesn't when i include .h files

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
/*
 * nec decoder.c
 *
 * Created: 11-05-2020 20:13:54
 * Author : jeet
 */ 

#define F_CPU 16000000UL

#include <avr/io.h>
#include <stdio.h>
#include <stdbool.h>
#include <avr/interrupt.h>

#include "uart.c"
#include "ir_nec.c"

static int uart_putchar(char c, FILE *stream);
static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,_FDEV_SETUP_WRITE);

static int uart_putchar(char c, FILE *stream)
{
	if (c == '\n')
	uart_putchar('\r', stream);
	loop_until_bit_is_set(UCSR0A, UDRE0);
	UDR0 = c;
	return 0;
}


int main(void)
{
	UART_Initialize();
	stdout = &mystdout;
	
	IR_Initialize();
	
	sei();
	
	while (1)
	{
		IR_ProcessData();	
		if (nec_new_data == true || nec_current_status == PACKET_RECVD_N_REPEAT_RECVNG)
		{
			nec_new_data = false;
			printf("nec_addrh=%u nec_addrl=%u nec_cmd=%u nec_cmdinv=%u\n",nec_current_packet.addr_h,nec_current_packet.addr_l,nec_current_packet.cmd,nec_current_packet.cmd_inv);
		}
	}
	
}

this is my main file and i have already made a post all other files can be seen at  https://www.avrfreaks.net/forum/unable-splitmodularize-my-project

Last Edited: Sat. Jul 4, 2020 - 02:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So why make a separate post here, then?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

awneil wrote:

So why make a separate post here, then?

 


Agree so locking this one. As I've said before start by learning C programming. Put the AVR off to obe side for the time being until you've done that.

Topic locked