Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Daryl Gallatin <dgall723@ma...> - 2002-12-05 02:48:23
|
Hi, I'm trying to compile a c program that will display a text string to an = LCD display. I know I have to use a pointer which I am doing, but it = doesn't work. I get a wierd warning that doesn't make sense to me lcddisplay.c(41):warning *** indirections to different types assignements = type --> 'array of const char' assigned to type --> 'unsigned int' I can still compile the program but it doesn't.=20 If I do a simple program for dos that uses pointers, I can get it to = display the text my program declarations are=20 void main(void) { uchar A; //declare an unsigned character varible int count; unsigned char *ptrA; //declare a pointer count=3D0; A=3D"Hello "; ptrA=3D&A; //Pointer ptrA points to the address location of the first = character of variable A The ptrA=3D&A is line 41. How is this an unsigned int? ... for(count=3D0;count<5;count++) =20 { LCDputchar(*ptrA); // Display the letter that the = pointer ptrA points to ptrA=3DptrA+1; //increment the address that pointer ptrA = points to by 1 } void LCDputchar(uchar value) { int i; P2=3Dvalue; ENABLE=3D1; for(i=3D0;i<125;i++); //delay ENABLE=3D0; } I can do an equivalent DOS program that works fine.=20 Thanks for any help DAryl |
From: Jesus Calvino-Fraga <JesusC@ec...> - 2002-12-05 09:46:44
|
Hi Daryl, This looks incorrect to me: uchar A; . . . A="Hello "; You are assigning a pointer to string to a char (I am assuming that "#define uchar unsigned char" is someplace in the file). Instead, it should look like: uchar * A; . . . A="Hello "; ptrA=A; //A is already a pointer so no '&' Jesus At 08:31 PM 12/4/02 -0600, Daryl Gallatin wrote: >Hi, >I'm trying to compile a c program that will display a text string to an >LCD display. I know I have to use a pointer which I am doing, but it >doesn't work. I get a wierd warning that doesn't make sense to me > >lcddisplay.c(41):warning *** indirections to different types assignements >type --> 'array of const char' assigned to type --> 'unsigned int' > >I can still compile the program but it doesn't. >If I do a simple program for dos that uses pointers, I can get it to >display the text > >my program declarations are > >void main(void) > { > uchar A; //declare an unsigned character varible > int count; > unsigned char *ptrA; //declare a pointer > > > > count=0; > A="Hello "; > ptrA=&A; //Pointer ptrA points to the address location of the first > character of variable A > >The ptrA=&A is line 41. How is this an unsigned int? >... > >for(count=0;count<5;count++) > { > LCDputchar(*ptrA); // Display the letter that the > pointer ptrA points to > ptrA=ptrA+1; //increment the address that pointer ptrA > points to by 1 > } > > > >void LCDputchar(uchar value) > { > int i; > P2=value; > ENABLE=1; > for(i=0;i<125;i++); //delay > ENABLE=0; > } > > >I can do an equivalent DOS program that works fine. >Thanks for any help > >DAryl > > > > >------------------------------------------------------- >This SF.net email is sponsored by: Microsoft Visual Studio.NET >comprehensive development tool, built to increase your >productivity. Try a free online hosted session at: >http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en >_______________________________________________ >Sdcc-user mailing list >Sdcc-user@... >https://lists.sourceforge.net/lists/listinfo/sdcc-user |
From: Bothe <Harald.Bothe@pt...> - 2002-12-05 10:11:58
|
> You are assigning a pointer to string to a char (I am assuming that > "#define uchar unsigned char" is someplace in the file). Instead, it > should look like: > > uchar * A; > . > . > . > A="Hello "; uchar A[255]; /* Your string needs storage ... */ strcpy (A, "Hello"); /* ... to be _copied_ into (in contrast to BASIC ;-)) */ or better use uchar A="Hello"; /* Assignment in one line*/ >> Hi, >> I'm trying to compile a c program that will display a text string to >> an LCD display. I know I have to use a pointer which I am doing, but >> it doesn't work. I get a wierd warning that doesn't make sense to me >> >> lcddisplay.c(41):warning *** indirections to different types >> assignements type --> 'array of const char' assigned to type --> >> 'unsigned int' >> >> I can still compile the program but it doesn't. >> If I do a simple program for dos that uses pointers, I can get it to >> display the text >> >> my program declarations are >> >> void main(void) >> { >> uchar A; //declare an unsigned character varible >> int count; >> unsigned char *ptrA; //declare a pointer >> >> >> >> count=0; >> A="Hello "; >> ptrA=&A; //Pointer ptrA points to the address location of the >> first character of variable A >> >> The ptrA=&A is line 41. How is this an unsigned int? >> ... >> >> for(count=0;count<5;count++) >> { >> LCDputchar(*ptrA); // Display the letter that the >> pointer ptrA points to >> ptrA=ptrA+1; //increment the address that pointer ptrA >> points to by 1 >> } >> >> >> >> void LCDputchar(uchar value) >> { >> int i; >> P2=value; >> ENABLE=1; >> for(i=0;i<125;i++); //delay >> ENABLE=0; >> } >> >> >> I can do an equivalent DOS program that works fine. >> Thanks for any help >> >> DAryl >> >> >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft Visual Studio.NET >> comprehensive development tool, built to increase your >> productivity. Try a free online hosted session at: >> http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en >> _______________________________________________ >> Sdcc-user mailing list >> Sdcc-user@... >> https://lists.sourceforge.net/lists/listinfo/sdcc-user > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@... > https://lists.sourceforge.net/lists/listinfo/sdcc-user > -- ---------------------------------------------------------------------- Dipl.-Ing. (FH) Harald Bothe eMail: Harald.Bothe@... Tel.: (05 31) 5 92 - 21 12 Physikalisch - Technische Bundesanstalt Fax: (05 31) 5 92 - 21 05 Fachlabor 2.11, Wechselstromgrößen Bundesallee 100 Postfach 33 45 38116 Braunschweig 38023 Braunschweig Germany ---------------------------------------------------------------------- |
From: Jesus Calvino-Fraga <JesusC@ec...> - 2002-12-05 10:46:59
|
At 11:11 AM 12/5/02 +0100, you wrote: >uchar A[255]; /* Your string needs storage ... */ The string as originally defined ("Hello") already has storage. It is in code memory. The line above requires valuable RAM (either external or internal, which is probably not enough since there are max 256 bytes available). >strcpy (A, "Hello"); /* ... to be _copied_ into (in contrast to BASIC >;-)) */ > >or better use > >uchar A="Hello"; /* Assignment in one line*/ Still, for the last line you are copying pointers, not strings. Therefore variable A will end up with part of the memory address where "Hello" is allocated. You could very well have done: uchar * A; . . A="Hello"; Or did you mean instead: uchar * A="Hello"; uchar A[]="Hello";? |
From: <MSoegtrop@Michael-Soegtrop.de> - 2002-12-06 09:37:11
|
Dear Darly, the question you put on the SDCC news group is quite a C beginners question. I really don't think that you do yourself a favour if you start programming C on a microcontroller. If your micrcontroller project is not completely trivial, i think it might be faster (and better for your health) if you first spend one week or two weeks to go through a C tutorial book using a PC C Complier and then start with your microcontroller project. Learning progress on a PC is usually much faster, because PC C Compilers have more comfortable debuggers and it is possible to work through a tutorial book on a PC. Microcontrollers usually have limitations, so that textbook examples won't compile or run on Microcontroller boards. I think that you should have programming experience in C without the limitations of a microcontroller, so that you know what doesn't work cause of these limitations and what doesn't work because it is simply wrong. Best regards, Michael > -----Original Message----- > From: sdcc-user-admin@... > [mailto:sdcc-user-admin@...]On Behalf Of Daryl > Gallatin > Sent: Thursday, December 05, 2002 3:32 AM > To: sdcc-user@... > Subject: [Sdcc-user] unsigned char to unsigned int warning > > > Hi, > I'm trying to compile a c program that will display a text > string to an LCD display. I know I have to use a pointer > which I am doing, but it doesn't work. I get a wierd warning > that doesn't make sense to me > > lcddisplay.c(41):warning *** indirections to different types > assignements type --> 'array of const char' assigned to type > --> 'unsigned int' > > I can still compile the program but it doesn't. > If I do a simple program for dos that uses pointers, I can > get it to display the text > > my program declarations are > > void main(void) > { > uchar A; //declare an unsigned character varible > int count; > unsigned char *ptrA; //declare a pointer > > > > count=0; > A="Hello "; > ptrA=&A; //Pointer ptrA points to the address location of > the first character of variable A > > The ptrA=&A is line 41. How is this an unsigned int? > ... > > for(count=0;count<5;count++) > { > LCDputchar(*ptrA); // Display the letter that > the pointer ptrA points to > ptrA=ptrA+1; //increment the address that > pointer ptrA points to by 1 > } > > > > void LCDputchar(uchar value) > { > int i; > P2=value; > ENABLE=1; > for(i=0;i<125;i++); //delay > ENABLE=0; > } > > > I can do an equivalent DOS program that works fine. > Thanks for any help > > DAryl > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Microsoft Visual Studio.NET > comprehensive development tool, built to increase your > productivity. Try a free online hosted session at: > http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@... > https://lists.sourceforge.net/lists/listinfo/sdcc-user |