This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

not able to use printf statement in keil uvision 4

not able to use printf statement in keil uvision 4

Parents
  • // Header:
    // File Name: serial_led.c
    // Author:
    // Date:          14/06/2007
    #include <stdio.h>
    #include "LPC214x.h"
    #include <string.h>
    #define CR     0x0D
    
    
    
    char sendchar1 (char ch);
    char getkey1(char ch);
    char getkey0(void);
    void init_serial0(void);
    void init_serial1(void);
    unsigned char Disp[]="UART1";
    
    
    
    
    void lcd_initialize(void);
    void LCD_puts(unsigned char *,  unsigned char);
    void lcd_cmd(unsigned char);
    void lcd_data(unsigned char);
    void delay1(unsigned int);
    void lcd_display(void);
    unsigned char msg[] = {"VEHICLE LOCATION"};                                           //msg
    unsigned char msg1[]= {"USING GSM & GPS"};
    
    void gets_USART(unsigned char *);
    void Get_GPS_USART0(unsigned char *);
    
    const unsigned char cmd[4] = {0x38,0x0c,0x06,0x01};     //lcd commands
    
    unsigned long int DATA;
    unsigned char Chr,i=0,Str_GPS[100],*ptr,LAT[]="LAT:",LAN[]="LAN:";
    unsigned  char str1[]="GPRMC";
    //char * strstr(unsigned char *GPS_Str, const char *str1);
    
    void delay (void)
    {
    
            unsigned int i,j;
            for(i=0;i<50;i++)
            {
                    for(j=0;j<50;j++)
                    {
                            ;
                    }
            }
    }
    
    int main(void)
    {
    
            unsigned char i=0;
    
            IODIR0  = 0xFFFFFFFF;
                    delay1(10);
    
                    IODIR0 = 0XFFFFFFFF;    //PORT [P0.16--P0.31] output
                    IODIR1 = 0X00Ff0000;    //PORT [P1.20--P1.23] output
                    delay1(10);
                    lcd_initialize();               //Initialize LCD
                    delay1(10);
                    delay1(15);
                    lcd_display();
                    delay1(15);
            init_serial1();
            init_serial0();
            while(1)
            {
                    init_serial0();
                    Get_GPS_USART0(Str_GPS);
                    lcd_cmd(0x80);
                    LCD_puts(LAT,4);
                    LCD_puts(ptr,11);
                    ptr = ptr+13;
            //      send_sms(ptr);
            lcd_cmd(0xC0);
                    LCD_puts(LAN,4);
                    LCD_puts(ptr,11);
                    //ch = getkey();
                    printf("\nUART0\n");
                    i=0;
                    delay();
                    U1THR = '\n';
                    while(Disp[i]!= '\0')   {
    
                            sendchar1(Disp[i++]);
                            delay();
                    }
                    U1THR = '\n';
                    sendchar1(0x20);
            }
    }
    
    
    
    
    //----------------------------------
    //              LCD Initialize
    //----------------------------------
    void lcd_initialize(void)
    {
            int i;
            for(i=0;i<4;i++)
            {
                    IOCLR0 = 0x00FF0000;
                    lcd_cmd(cmd[i]);
                    delay1(15);
            }
    
    }
    
    //----------------------------------
    //              LCD Command Send
    //----------------------------------
    void lcd_cmd(unsigned char data)
    {
            IOPIN0  = data << 16;
            IOCLR1  |= 0x100000;            //RS
            IOCLR1  |= 0x200000;            //RW
            IOSET1  |= 0x400000;            //EN
            delay1(15);
            IOCLR1  |= 0x400000;            //EN
    }
    
    
    
    //----------------------------------
    //              LCD Data Send
    //----------------------------------
    void lcd_data(unsigned char data)
    {
            IOPIN0  = data << 16;
            IOSET1  |= 0x100000;            //RS
            IOCLR1  |= 0x200000;            //RW
            IOSET1  |= 0x400000;            //EN
            delay1(15);
            IOCLR1  |= 0x400000;            //EN
    }
    
    
    
    
    //----------------------------------
    //              LCD Display Msg
    //----------------------------------
    void lcd_display(void)
    {
            char i;
    
            /* First line message */
            IOCLR0 = 0x00FF0000;
            lcd_cmd(0x80);
            delay1(15);
            i=0;
            while(msg[i]!='\0')
                    {
                            IOCLR0 = 0x00FF0000;
                            lcd_data(msg[i]);
                            i++;
                            delay1(15);
                    }
            delay1(15);
                    /* sECOND line message */
            IOCLR0 = 0x00FF0000;
            lcd_cmd(0xC0);
            delay1(15);
            i=0;
            while(msg1[i]!='\0')
                    {
                            IOCLR0 = 0x00FF0000;
                            lcd_data(msg1[i]);
                            i++;
                            delay1(15);
                    }
            delay1(15);
    
            }
    
    void LCD_puts(unsigned char *string, unsigned char n)
    {
            while((*string) && ((n--)>0))
            lcd_data(*string++);
    }
    
    
    void gets_USART0(unsigned char *string)                                  //  Receive a batch of characters via USART1, without interrupt
    {
                                                                                                             //  The String Must Ended with "Carriage return" ie "Enter key"
            unsigned char i=0,J=0;
    
            do
            {
                    *(string+i)= getkey0();
                     J = *(string+i);
                     i++;
            }while((J!='\n') && (J!='\r'));
            i++;
            *(string+i) = '\0';
    }
    
    void Get_GPS_USART0(unsigned char *GPS_Str)
    {
            gets_USART0(GPS_Str);
    
            while(!(strstr(GPS_Str,str1))) gets_USART0(GPS_Str);
            ptr = strstr(GPS_Str,str1)+19;
    }
    
    void delay1(unsigned int Ms)
    {
            int delay_cnst;
            while(Ms>0)
            {
                    Ms--;
                    for(delay_cnst = 0;delay_cnst <220;delay_cnst++);
            }
    }
    

    this is my code i am getting that warning argument of type unsigned char* is incompatible with const char* in strstr function

Reply
  • // Header:
    // File Name: serial_led.c
    // Author:
    // Date:          14/06/2007
    #include <stdio.h>
    #include "LPC214x.h"
    #include <string.h>
    #define CR     0x0D
    
    
    
    char sendchar1 (char ch);
    char getkey1(char ch);
    char getkey0(void);
    void init_serial0(void);
    void init_serial1(void);
    unsigned char Disp[]="UART1";
    
    
    
    
    void lcd_initialize(void);
    void LCD_puts(unsigned char *,  unsigned char);
    void lcd_cmd(unsigned char);
    void lcd_data(unsigned char);
    void delay1(unsigned int);
    void lcd_display(void);
    unsigned char msg[] = {"VEHICLE LOCATION"};                                           //msg
    unsigned char msg1[]= {"USING GSM & GPS"};
    
    void gets_USART(unsigned char *);
    void Get_GPS_USART0(unsigned char *);
    
    const unsigned char cmd[4] = {0x38,0x0c,0x06,0x01};     //lcd commands
    
    unsigned long int DATA;
    unsigned char Chr,i=0,Str_GPS[100],*ptr,LAT[]="LAT:",LAN[]="LAN:";
    unsigned  char str1[]="GPRMC";
    //char * strstr(unsigned char *GPS_Str, const char *str1);
    
    void delay (void)
    {
    
            unsigned int i,j;
            for(i=0;i<50;i++)
            {
                    for(j=0;j<50;j++)
                    {
                            ;
                    }
            }
    }
    
    int main(void)
    {
    
            unsigned char i=0;
    
            IODIR0  = 0xFFFFFFFF;
                    delay1(10);
    
                    IODIR0 = 0XFFFFFFFF;    //PORT [P0.16--P0.31] output
                    IODIR1 = 0X00Ff0000;    //PORT [P1.20--P1.23] output
                    delay1(10);
                    lcd_initialize();               //Initialize LCD
                    delay1(10);
                    delay1(15);
                    lcd_display();
                    delay1(15);
            init_serial1();
            init_serial0();
            while(1)
            {
                    init_serial0();
                    Get_GPS_USART0(Str_GPS);
                    lcd_cmd(0x80);
                    LCD_puts(LAT,4);
                    LCD_puts(ptr,11);
                    ptr = ptr+13;
            //      send_sms(ptr);
            lcd_cmd(0xC0);
                    LCD_puts(LAN,4);
                    LCD_puts(ptr,11);
                    //ch = getkey();
                    printf("\nUART0\n");
                    i=0;
                    delay();
                    U1THR = '\n';
                    while(Disp[i]!= '\0')   {
    
                            sendchar1(Disp[i++]);
                            delay();
                    }
                    U1THR = '\n';
                    sendchar1(0x20);
            }
    }
    
    
    
    
    //----------------------------------
    //              LCD Initialize
    //----------------------------------
    void lcd_initialize(void)
    {
            int i;
            for(i=0;i<4;i++)
            {
                    IOCLR0 = 0x00FF0000;
                    lcd_cmd(cmd[i]);
                    delay1(15);
            }
    
    }
    
    //----------------------------------
    //              LCD Command Send
    //----------------------------------
    void lcd_cmd(unsigned char data)
    {
            IOPIN0  = data << 16;
            IOCLR1  |= 0x100000;            //RS
            IOCLR1  |= 0x200000;            //RW
            IOSET1  |= 0x400000;            //EN
            delay1(15);
            IOCLR1  |= 0x400000;            //EN
    }
    
    
    
    //----------------------------------
    //              LCD Data Send
    //----------------------------------
    void lcd_data(unsigned char data)
    {
            IOPIN0  = data << 16;
            IOSET1  |= 0x100000;            //RS
            IOCLR1  |= 0x200000;            //RW
            IOSET1  |= 0x400000;            //EN
            delay1(15);
            IOCLR1  |= 0x400000;            //EN
    }
    
    
    
    
    //----------------------------------
    //              LCD Display Msg
    //----------------------------------
    void lcd_display(void)
    {
            char i;
    
            /* First line message */
            IOCLR0 = 0x00FF0000;
            lcd_cmd(0x80);
            delay1(15);
            i=0;
            while(msg[i]!='\0')
                    {
                            IOCLR0 = 0x00FF0000;
                            lcd_data(msg[i]);
                            i++;
                            delay1(15);
                    }
            delay1(15);
                    /* sECOND line message */
            IOCLR0 = 0x00FF0000;
            lcd_cmd(0xC0);
            delay1(15);
            i=0;
            while(msg1[i]!='\0')
                    {
                            IOCLR0 = 0x00FF0000;
                            lcd_data(msg1[i]);
                            i++;
                            delay1(15);
                    }
            delay1(15);
    
            }
    
    void LCD_puts(unsigned char *string, unsigned char n)
    {
            while((*string) && ((n--)>0))
            lcd_data(*string++);
    }
    
    
    void gets_USART0(unsigned char *string)                                  //  Receive a batch of characters via USART1, without interrupt
    {
                                                                                                             //  The String Must Ended with "Carriage return" ie "Enter key"
            unsigned char i=0,J=0;
    
            do
            {
                    *(string+i)= getkey0();
                     J = *(string+i);
                     i++;
            }while((J!='\n') && (J!='\r'));
            i++;
            *(string+i) = '\0';
    }
    
    void Get_GPS_USART0(unsigned char *GPS_Str)
    {
            gets_USART0(GPS_Str);
    
            while(!(strstr(GPS_Str,str1))) gets_USART0(GPS_Str);
            ptr = strstr(GPS_Str,str1)+19;
    }
    
    void delay1(unsigned int Ms)
    {
            int delay_cnst;
            while(Ms>0)
            {
                    Ms--;
                    for(delay_cnst = 0;delay_cnst <220;delay_cnst++);
            }
    }
    

    this is my code i am getting that warning argument of type unsigned char* is incompatible with const char* in strstr function

Children