Hi,
First the good news. Thanks to you people I now have been able to make few test projects with my mutilated Arduino project files. Basically I took a sample Arduino project and removed everything except main.c and just used avr/io.h and port manipulation.
And now in the series of stupid questions… This is closely related to Moving from Arduino IDE to Embeetle - #12 by joyzpa
My test project works when it’s all in one file (this has been gone over in way too many forums already, but please endure ) The problem is caused by me dividing my test project (to learn the real way of coding after discovering the hidden world behind Arduino IDE) main.c in to 3 source files, to main.c, USART.c and USART.h. I presume that this is some error that I have made in the file inclusion, but I don’t seem to be able to find the problem. The project is a serial test code that just mirrors back the received bytes and it can be found from Atmega328P manual.
Problem:
Diagnostics show no errors
But when compiling, beetle throws an error
Very much likely caused by not included (linked) source file USART.c (forced inclusion via filetree doesn’t help)
I have tried making the source file inclusion and function prototypes as stated in the ANDI C book, but obviously it seems that I failed.
I’ll list my code here and the code inside functions is simplified with { … } (it is not sensitive but its too long for comfort, if required I’ll just send the whole project ).
main.c
#include <avr/io.h>
#include "USART.h"
int main(void)
{
USART_Init(103); // set baudrate register to desired baudrate value see UBRRn table
do { // so called main loop
USART_Transmit(USART_Receive()); // loopback all received
} while (1);
return 0;
}
USART.h
#ifndef USART_H
#define USART_H
// Includes, defines(macros)
// Function prototypes
static unsigned char USART_Receive(void);
static void USART_Transmit(unsigned char data);
static void USART_Init(unsigned int ubrr);
#endif
USART.c
// includes, defines
#include <avr/io.h>
#include "USART.h"
static unsigned char USART_Receive(void) { ... }
static void USART_Transmit(unsigned char data) { ... }
static void USART_Init(unsigned int ubrr) { ... }
If by any change you people can spot the problem, I would be very happy
As a reminder, this is a Arduino sample project (downloaded from beetle server) that I have mutilated by removing all Arduino lib’s, so it might be possible that i.e. Arduino linker script is malfunctioning because of my doing. I had to start in this way since i had absolutely no idea, how to create a empty Atmega328P project with Embeetle, i.e. how to arrange the project directories, where to get makefile, linker script etc.
All in all, I’m in love with the Embeetle, I’m just having some trouble getting started
Niko