EmbeddedRelated.com
Forums

[AVR club] errors in codevisinavr for running hc05 bluetooth module with atmega8L

Started by "moh...@rocketmail.com [avrclub]" July 4, 2016
hello every one

i want to run hc05 bluetooth module with atmega8L by following codes in codevisionavr ,main project file is hc11.c and it has 2 header files named hc05.h and usart.h but i see some errors and warnings after selecting build all , codes are:

hc11.c



hc05.h



usart.h



errors:
Error: C:\cvavreval\inc\usart.h(55), included from: hc05.h: declaration syntax error
Error: C:\cvavreval\inc\usart.h(98), included from: hc05.h: must declare first in block
Error: C:\cvavreval\inc\usart.h(105), included from: hc05.h: must declare first in block
Error: C:\cvavreval\inc\usart.h(109), included from: hc05.h: 'void' functions may not return a value
Error: C:\cvavreval\inc\usart.h(112), included from: hc05.h: must declare first in block
Error: C:\cvavreval\inc\usart.h(127), included from: hc05.h: undefined symbol 'usart_data_receive'
Error: C:\cvavreval\inc\usart.h(134), included from: hc05.h: 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(41): function 'main' has already been defined in file: 'C:\Users\MY MHCE\Desktop\New folder\project\hc11\hc11.c', line: 40
Error: C:\cvavreval\inc\hc05.h(46): declaration syntax error
Error: C:\cvavreval\inc\hc05.h(76): undefined symbol 'usart_data_receive'
Error: C:\cvavreval\inc\hc05.h(83): 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(85): must declare first in block
Error: C:\cvavreval\inc\hc05.h(89): undefined symbol 'usart_string_transmit'
Error: C:\cvavreval\inc\hc05.h(100): 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(104): must declare first in block
Error: C:\cvavreval\inc\hc05.h(111): undefined symbol 'usart_string_transmit'
Error: C:\cvavreval\inc\hc05.h(153): undefined symbol 'usart_data_transmit'
Error: C:\cvavreval\inc\hc05.h(164): 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(168): must declare first in block
Error: C:\cvavreval\inc\hc05.h(173): undefined symbol 'usart_string_transmit'
Error: C:\cvavreval\inc\hc05.h(187): 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(192): must declare first in block
Error: C:\cvavreval\inc\hc05.h(198): undefined symbol 'usart_string_transmit'
Error: C:\cvavreval\inc\hc05.h(217): 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(221): 'void' functions may not return a value
Error: C:\cvavreval\inc\hc05.h(225): must declare first in block
Error: C:\cvavreval\inc\hc05.h(230): undefined symbol 'usart_string_transmit'
Error: C:\cvavreval\inc\hc05.h(244): 'void' functions may not return a value

warnings:
Warning: C:\cvavreval\inc\usart.h(102), included from: hc05.h: local variable 'data' is used before its value is set
Warning: C:\cvavreval\inc\usart.h(127), included from: hc05.h: local variable 'receive_string' is used before its value is set
Warning: C:\cvavreval\inc\usart.h(133), included from: hc05.h: local variable 'receive_string' is used before its value is set
Warning: C:\cvavreval\inc\usart.h(134), included from: hc05.h: local variable 'receive_string' is used before its value is set
Warning: C:\cvavreval\inc\hc05.h(76): local variable 'receive_string' is used before its value is set
Warning: C:\cvavreval\inc\hc05.h(82): local variable 'receive_string' is used before its value is set
Warning: C:\cvavreval\inc\hc05.h(83): local variable 'receive_string' is used before its value is set
Warning: C:\cvavreval\inc\hc05.h(109): local variable 'baud_rate' is used before its value is set
Warning: C:\cvavreval\inc\hc05.h(208): local variable 'hc_05_buffer2' is used before its value is set
Warning: C:\cvavreval\inc\hc05.h(210): local variable 'hc_05_buffer2' is used before its value is set

for solving errors i declared variables after header files but nothing changed in errors,and also i cut unsigned before variable and again same thing occured , some where i read that i should active gcc mode i do that by these codes:

#include

void main(int) {
set_sleep_mode(SLEEP_MODE_IDLE);
sei();
sleep_mode();
}

(also i took this code from the net)

and i did not see those errors but i saw just this error:
Error: C:\cvavreval\inc\usart.h(40), included from: hc05.h: invalid #include directive

that line 40 is:
void main(int) {

and i change it to : void main() or: void main(void)

but i saw again the same error,these codes are in c++ but as you know better than me codevisionavr is a c compiler and also I lernt c++ in university and do not know how to change it to c till be accepted by this compiler ,please learn me which code I should add in my codes , it is my class project and I could not change my compiler because my programmer just support this type,I really need your help!!!
Hi - It would be far better to paste the code into pastebin or some other online place where we can figure out the lines on the code, and see what's causing the errors; Swamped here today so I can't spend much time on figuring out what line in the code each error came from etc... Going to be a busy weekend for me. You should be able to look at the lines that are offending the compiler though, and figure out what the compiler doesn't like and fix it?

I sort of wish ideone or the like had a way to put include files in there as well, it really would help :)
  Mark
From: "m...@rocketmail.com [avrclub]"
To: a...
Sent: Monday, July 4, 2016 4:41 AM
Subject: [AVR club] errors in codevisinavr for running hc05 bluetooth module with atmega8L



hello every onei want to run hc05 bluetooth module  with atmega8L by following codes in codevisionavr ,main project file is hc11.c and it has 2 header files named  hc05.h  and  usart.h but i see some errors and warnings after selecting build all  ,   codes are:
hc11.c


hc05.h    usart.h  

errors:Error: C:\cvavreval\inc\usart.h(55), included from: hc05.h: declaration syntax errorError: C:\cvavreval\inc\usart.h(98), included from: hc05.h: must declare first in blockError: C:\cvavreval\inc\usart.h(105), included from: hc05.h: must declare first in blockError: C:\cvavreval\inc\usart.h(109), included from: hc05.h: 'void' functions may not return a valueError: C:\cvavreval\inc\usart.h(112), included from: hc05.h: must declare first in blockError: C:\cvavreval\inc\usart.h(127), included from: hc05.h: undefined symbol 'usart_data_receive'Error: C:\cvavreval\inc\usart.h(134), included from: hc05.h: 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(41): function 'main' has already been defined in file: 'C:\Users\MY MHCE\Desktop\New folder\project\hc11\hc11.c', line: 40Error: C:\cvavreval\inc\hc05.h(46): declaration syntax errorError: C:\cvavreval\inc\hc05.h(76): undefined symbol 'usart_data_receive'Error: C:\cvavreval\inc\hc05.h(83): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(85): must declare first in blockError: C:\cvavreval\inc\hc05.h(89): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(100): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(104): must declare first in blockError: C:\cvavreval\inc\hc05.h(111): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(153): undefined symbol 'usart_data_transmit'Error: C:\cvavreval\inc\hc05.h(164): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(168): must declare first in blockError: C:\cvavreval\inc\hc05.h(173): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(187): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(192): must declare first in blockError: C:\cvavreval\inc\hc05.h(198): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(217): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(221): 'void' functions may not return a valueError: C:\cvavreval\inc\hc05.h(225): must declare first in blockError: C:\cvavreval\inc\hc05.h(230): undefined symbol 'usart_string_transmit'Error: C:\cvavreval\inc\hc05.h(244): 'void' functions may not return a value

warnings:Warning: C:\cvavreval\inc\usart.h(102), included from: hc05.h: local variable 'data' is used before its value is setWarning: C:\cvavreval\inc\usart.h(127), included from: hc05.h: local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\usart.h(133), included from: hc05.h: local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\usart.h(134), included from: hc05.h: local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(76): local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(82): local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(83): local variable 'receive_string' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(109): local variable 'baud_rate' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(208): local variable 'hc_05_buffer2' is used before its value is setWarning: C:\cvavreval\inc\hc05.h(210): local variable 'hc_05_buffer2' is used before its value is set
for solving errors i declared variables after header files but nothing changed in errors,and also i cut unsigned before variable and again same thing occured , some where i read that i should active gcc mode i do that by  these  codes:
#include 
void main(int) {  set_sleep_mode(SLEEP_MODE_IDLE);  sei();  sleep_mode();}
(also i took this code from the net)
and i did not see those errors but i saw just this error:Error: C:\cvavreval\inc\usart.h(40), included from: hc05.h: invalid #include directive

that line 40 is:void main(int) {

and i change it to :  void main()  or:  void main(void)

but i saw again the same error,these codes are in c++ but as you know better than me codevisionavr is a c compiler and also I lernt c++ in university and do not know how to change it to c till be accepted by this compiler ,please learn me which code I should add in my codes , it is my class project and I could not change my compiler  because my programmer just support this type,I really need your help!!!
i corrected my codes and i when i compiled it i saw just this error: Error: C:\cvavreval\inc\usart.h(185), included from: hc05.h: invalid #include directive

line 185 of usart.h:
void usart_init();

then when i check syntax error i saw this error:
Error: C:\cvavreval\inc\usart.h(272): no matching #endif

line 272 of usart.h is:
#endif

please learn me how change my code.
i changed my codes and errors disappeared.