اطلاعیه

Collapse
No announcement yet.

ارورهای کدویژن

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    ارورهای کدویژن

    سلام,من یه سری کدبرای راه اندازی ماژول بلوتوثhc05وatmega8Lدارم که توکدویژن ارور میده:
    اینم کدهام:hc1.c
    #include<io.h>
    /*Includes io.h header file where all the Input/Output Registers and its Bits are defined for all AVR microcontrollers*/

    #define F_CPU 8000000
    /*Defines a macro for the delay.h header file. F_CPU is the microcontroller frequency value for the delay.h header file. Default value of F_CPU in delay.h header file is 1000000(1MHz)*/
    #include<delay.h>
    /*Includes delay.h header file which defines two functions, _delay_ms (millisecond delay) and _delay_us (microsecond delay)*/
    #include<hc05.h>
    /*Includes hc05.h header file which defines different functions for HC-05 Bluetooth Module. HC-05 header file version is 1.1*/

    void main(void)
    {
    delay_ms(500);
    delay_ms(500);
    /*Delay of 1s*/

    usart_init();
    /*USART initialization*/

    hc_05_bluetooth_transmit_string("ABLab Solutions");
    /*Transmits a string to Bluetooth Module*/
    hc_05_bluetooth_transmit_byte(0x0d);
    /*Transmits Carriage return to Bluetooth Module*/

    hc_05_bluetooth_transmit_byte(0x0a);
    /*Transmits New Line to Bluetooth Module for new line*/
    hc_05_bluetooth_transmit_string("www.ablab.in");
    /*Transmits a string to Bluetooth Module*/
    hc_05_bluetooth_transmit_byte(0x0d);
    /*Transmits Carriage return to Bluetooth Module*/

    hc_05_bluetooth_transmit_byte(0x0a);
    /*Transmits New Line to Bluetooth Module for new line*/
    }
    /*End of program*/

    - - - Updated - - -

    hc05.h


    #ifndef _HC05_H_
    #define _HC05_H_ 1

    #include<io.h>
    #include<delay.h>
    #include<usart.h>
    char hc_05_buffer1[25], hc_05_buffer2[50];
    char temp;
    void hc_05_bluetooth_transmit_byte(char data_byte);
    char hc_05_bluetooth_receive_byte(void);
    void hc_05_bluetooth_transmit_string(char *transmit_string);
    void hc_05_bluetooth_transmit_command(char *transmit_string);
    char *hc_05_bluetooth_receive_string(char *receive_string, unsigned char terminating_character);
    unsigned char hc_05_bluetooth_at_command_mode_test(void);
    unsigned char hc_05_bluetooth_device_name_change(char *device_name);
    unsigned char hc_05_bluetooth_get_version(void);
    unsigned char hc_05_bluetooth_change_baud_rate(long int baud_rate);
    unsigned char hc_05_bluetooth_pin_change(char *new_pin);

    void hc_05_bluetooth_transmit_byte(char data_byte)
    {
    usart_data_transmit(data_byte);
    }
    char hc_05_bluetooth_receive_byte(void)
    {
    return usart_data_receive();
    }
    void hc_05_bluetooth_transmit_string(char *transmit_string)
    {
    usart_string_transmit(transmit_string);
    }
    char *hc_05_bluetooth_receive_string(char *receive_string, unsigned char terminating_character)
    {
    unsigned char temp=0x00;
    for(unsigned char i=0;;i++)
    {
    *(receive_string+i)=usart_data_receive();
    if(*(receive_string+i)==terminating_character)
    break;
    else
    temp++;
    }
    *(receive_string+temp)='\0';
    return receive_string;
    }
    unsigned char hc_05_bluetooth_at_command_mode_test(void)
    {
    UBRRL=12;
    delay_ms(500);
    usart_string_transmit("AT");
    usart_data_transmit(0x0d);
    usart_data_transmit(0x0a);
    usart_string_receive(hc_05_buffer1,0x0d);
    temp=usart_data_receive();
    if(!(strcmp(hc_05_buffer1,"OK")))
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }
    unsigned char hc_05_bluetooth_change_baud_rate(long int baud_rate)
    {
    UBRRL=12;
    delay_ms(500);

    if(baud_rate==4800)
    {
    usart_string_transmit("AT+UART=4800,0,0");
    }
    else if(baud_rate==9600)
    {
    usart_string_transmit("AT+UART=9600,0,0");
    }
    else if(baud_rate==19200)
    {
    usart_string_transmit("AT+UART=19200,0,0");
    }
    else if(baud_rate==38400)
    {
    usart_string_transmit("AT+UART=38400,0,0");
    }
    else if(baud_rate==57600)
    {
    usart_string_transmit("AT+UART=57600,0,0");
    }
    else if(baud_rate==115200)
    {
    usart_string_transmit("AT+UART=115200,0,0");
    }
    else if(baud_rate==230400)
    {
    usart_string_transmit("AT+UART=230400,0,0");
    }
    else if(baud_rate==460800)
    {
    usart_string_transmit("AT+UART=460800,0,0");
    }
    else if(baud_rate==921600)
    {
    usart_string_transmit("AT+UART=921600,0,0");
    }
    else if(baud_rate==1382400)
    {
    usart_string_transmit("AT+UART=1382400,0,0");
    }
    else
    {
    ;
    }
    usart_data_transmit(0x0d);
    usart_data_transmit(0x0a);
    usart_string_receive(hc_05_buffer1,13);
    temp=usart_data_receive();

    if(!(strcmp(hc_05_buffer1,"OK")))
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }
    unsigned char hc_05_bluetooth_device_name_change(char *device_name)
    {
    UBRRL=12;
    delay_ms(500);

    usart_string_transmit("AT+NAME=");
    usart_string_transmit(device_name);
    usart_data_transmit(0x0d);
    usart_data_transmit(0x0a);

    usart_string_receive(hc_05_buffer1,13);
    temp=usart_data_receive();

    if(!(strcmp(hc_05_buffer1,"OK")))
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }
    unsigned char hc_05_bluetooth_get_version(void)
    {
    UBRRL=12;
    delay_ms(500);

    unsigned char i=9,j=0;
    usart_string_transmit("AT+VERSION?");
    usart_data_transmit(0x0d);
    usart_data_transmit(0x0a);

    usart_string_receive(hc_05_buffer2,13);
    temp=usart_data_receive();

    usart_string_receive(hc_05_buffer1,13);
    temp=usart_data_receive();

    for(i=9;hc_05_buffer2[i]!=0;i++)
    {
    hc_05_buffer2[j]=hc_05_buffer2[i];
    j++;
    }
    hc_05_buffer2[j]=0;

    if(!(strcmp(hc_05_buffer1,"OK")))
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }
    unsigned char hc_05_bluetooth_pin_change(char *new_pin)
    {
    UBRRL=12;
    delay_ms(500);

    usart_string_transmit("AT+PSWD=");
    usart_string_transmit(new_pin);
    usart_data_transmit(0x0d);
    usart_data_transmit(0x0a);

    usart_string_receive(hc_05_buffer1,13);
    temp=usart_data_receive();

    if(!(strcmp(hc_05_buffer1,"OK")))
    {
    return 1;
    }
    else
    {
    return 0;
    }
    }
    #endif

    - - - Updated - - -

    usart.h




    #ifndef _USART_H_
    #define _USART_H_ 1



    #include<io.h>
    #include<delay.h>


    /*The function is declared to initialize the USART with following cinfiguration:-
    USART mode - Asynchronous
    Baud rate - 9600
    Data bits - 8
    Stop bit - 1
    Parity - No parity.*/
    void usart_init();



    /*The function is declared to transmit data.*/
    void usart_data_transmit(unsigned char data );



    /*The function is declared to receive data.*/
    unsigned char usart_data_receive( void );



    /*The function is declared to transmit string.*/
    void usart_string_transmit(char *string);



    /*The function is declared to receive string.*/
    char *usart_string_receive(char *receive_string,unsigned char terminating_character);


    /*Function defination*/
    void usart_init()
    {
    UBRRH = 0;
    UBRRL =51;
    UCSRB|= (1<<RXEN)|(1<<TXEN);
    UCSRC |= (1 << URSEL)|(3<<UCSZ0);
    }

    void usart_data_transmit(unsigned char data )
    {
    while ( !( UCSRA & (1<<UDRE)) )
    ;
    UDR = data;
    }
    unsigned char usart_data_receive( void )
    {
    while ( !(UCSRA & (1<<RXC)) )
    ;
    return UDR;
    }
    void usart_string_transmit(char *string)
    {
    while(*string)
    {
    usart_data_transmit(*string++);
    }
    }
    char *usart_string_receive(char *receive_string,unsigned char terminating_character)
    {
    unsignedchar temp=0x00;
    for(unsignedchar i=0;;i++)
    {
    *(receive_string+i)=usart_data_receive();
    if(*(receive_string+i)==terminating_character)
    break;
    else
    temp++;
    }
    *(receive_string+temp)='\0';
    return receive_string;
    }
    #endif

    - - - Updated - - -

    واینم ارور هاش:

    Error: C:\cvavr\inc\usart.h(113): undefined symbol 'unsignedchar'
    Error: C:\cvavr\inc\usart.h(114): undefined symbol 'unsignedchar'
    Error: C:\cvavr\inc\usart.h(114): undefined symbol 'i'
    Error: C:\cvavr\inc\usart.h(117): undefined symbol 'i'
    Error: C:\cvavr\inc\usart.h(120): undefined symbol 'temp'
    Error: C:\cvavr\inc\usart.h(122): undefined symbol 'temp'

    - - - Updated - - -

    ادامه ی ارورها:

    Error: C:\cvavr\INC\hc05.h(34): can't open #include file: usart.h
    Error: C:\cvavr\INC\hc05.h(53): undefined symbol 'usart_data_transmit'
    Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'unsigned'
    Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'i'
    Error: C:\cvavr\INC\hc05.h(81): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(90): no matching if
    Error: C:\cvavr\INC\hc05.h(103): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(145): undefined symbol 'usart_data_transmit'
    Error: C:\cvavr\INC\hc05.h(34): can't open #include file: usart.h
    Error: C:\cvavr\INC\hc05.h(53): undefined symbol 'usart_data_transmit'
    Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'unsigned'
    Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'i'
    Error: C:\cvavr\INC\hc05.h(81): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(90): no matching if
    Error: C:\cvavr\INC\hc05.h(103): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(145): undefined symbol 'usart_data_transmit'
    Error: C:\cvavr\INC\hc05.h(154): no matching if
    Error: C:\cvavr\INC\hc05.h(165): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(177): no matching if
    Error: C:\cvavr\INC\hc05.h(187): must declare first in block
    Error: C:\cvavr\INC\hc05.h(188): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(205): undefined symbol 'strcmp'
    Error: C:\cvavr\INC\hc05.h(209): no matching if
    Error: C:\cvavr\INC\hc05.h(220): undefined symbol 'usart_string_transmit'
    Error: C:\cvavr\INC\hc05.h(232): no matching if







    درخواست کمک فوری لطفاً ,خداخیرتون بده....
لطفا صبر کنید...
X