Daafi Abdu
Newbie level 1
- Joined
- Feb 23, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 34
Im getting this warrning
I want to show characters on the LCD, here is my code
Please suggest me something to solve this warning issue 8-O
PIC18F4520\main.c:42:Warning [2054] suspicious pointer conversion
I want to show characters on the LCD, here is my code
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 /* Main.c file generated by New Project wizard * * Created: Fri Feb 21 2014 * Processor: PIC18F4520 * Compiler: MPLAB C18 */ #include <p18f4520.h> #include <stdlib.h> #include <delays.h> #include <string.h> /****************PIN DETAILS****************/ #define LCD_data PORTC // LCD Data port #define LCD_C7 PORTCbits.RC7 // LCD C7/Busy Flag #define LCD_rs PORTDbits.RD0 // LCD Register Select #define LCD_en PORTDbits.RD1 // LCD Enable #define LCD_rw PORTDbits.RD2 // LCD Read/Write /*******************************************/ /******************FUNCTION PROTOTYPE*******************/ void LCD_init(void); void LCD_busy(void); void LCD_command(unsigned char var); void LCD_senddata(unsigned char var); void LCD_sendstring(unsigned char *var); /*******************************************/ void main() { TRISC = 0x00; LATC = 0x00; TRISD = 0x00; LATD = 0x00; LCD_init(); //LCD_senddata('W'); //Delay10KTCYx (25); LCD_sendstring("LCD Tutorial"); //Delay10KTCYx (25); } /******************FUNCTION PROTOTYPE*******************/ /* Initialization by internal Reset Circuit */ void LCD_init() { LCD_data = 0x38; //Function set: 2 Line, 8-bit, 5x7 dots LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command LCD_data = 0x0F; //Display on, Curser blinking command LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command LCD_data = 0x01; //Clear LCD LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command LCD_data = 0x06; //Entry mode, auto increment with no shift LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in data register LCD_en = 1; //Enable H->L LCD_busy(); } /* Steps to read busy flag */ void LCD_busy() { LCD_C7 = 1; //Make C7th bit of LCD as i/p LCD_en = 1; //Make port pin as o/p LCD_rs = 0; //Selected command register LCD_rw = 1; //We are reading while(LCD_C7 > 0) { //read busy flag again and again till it becomes 0 LCD_en = 0; //Enable H->L LCD_en = 1; } } /* Sending Commands to LCD */ void LCD_command(unsigned char var) { LCD_data = var; //Function set: 2 Line, 8-bit, 5x7 dots LCD_rs = 0; //Selected command register LCD_rw = 0; //We are writing in instruction register LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command } // Using the above function is really simple // var will carry the command for LCD // e.g. // // LCD_command(0x01); /* Setting cursor position on LCD */ /*LCD_command(0x83);*/ /* Sending Data to LCD */ void LCD_senddata(unsigned char var) { LCD_data = var; //Function set: 2 Line, 8-bit, 5x7 dots LCD_rs = 1; //Selected data register LCD_rw = 0; //We are writing LCD_en = 1; //Enable H->L LCD_en = 0; LCD_busy(); //Wait for LCD to process the command } // Using the above function // we will pass the character to display as argument to function // e.g. // // LCD_senddata('A'); /* if we have a string to send to LCD? */ void LCD_sendstring(unsigned char *var) { while(*var) { //till string ends LCD_senddata(*var); //send characters one by one var++; } } // Using the above function // we will pass the string directly to the function // e.g. // // LCD_sendstring("LCD Tutorial"); /*******************************************/
Please suggest me something to solve this warning issue 8-O
Last edited by a moderator: