![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi, I have attached my code for correction since i am getting warning as Warning [2054] suspicious pointer conversion [CODE] #include"string.h" // is included void main() { printlcd1(" Hello world "); } void printlcd1(unsigned char *str) { unsigned char len,i;//RCIE=0; len = strlen(str); set_add(0x80); //sets display position in the first line for(i=0;i<len;i++) { data_lcd(*str); //displays the character on LCD str++; } //return; }[CODE] Above is the code when i build i am getting warning as Warning [2054] suspicious pointer conversion wat corrections is to be made kindly reply for this | |
| |
| | #2 |
|
There are two kinds of pointers on a Pic chip. One to ram and one to rom. Your function is defaulting to a ram pointer and the constant data "Hello World" is in rom. There are two ways to fix this. First make them both rom pointers, Code: printlcd1((rom unsigned char*)" Hello world "); void printlcd1(rom unsigned char *str) Note that strlen expects a ram pointer so you would be better doing something like, Code: while(*str){
data_lcd(*str); //displays the character on LCD
str++;
}
| |
| |
| | #3 |
|
Thanks it worked
| |
| |
|
| Tags |
| c18, compiler, functions, pointer, problem |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Strange Problem Encountered Using MicroChip MPLAB IDE C Compiler | skyflyer54 | Micro Controllers | 48 | 10th July 2008 10:14 AM |
| C18 PIC18F4550 pointer problem | HerbertMunch | Micro Controllers | 7 | 30th January 2008 06:58 PM |
| rtos_msg_send problem.. ccs c compiler | overmind | Micro Controllers | 7 | 22nd January 2008 02:13 AM |
| MC18 compiler. C pointer question. | HerbertMunch | Micro Controllers | 3 | 8th January 2008 05:39 PM |
| Problem setting up timer Interrupt using C18 compiler | elec123 | Micro Controllers | 4 | 14th November 2007 11:59 AM |