However its giving an error in mentioned line that
function argument #1 of type 'flash unsigned char[2]' is incompatible with required parameter of type 'unsigned char'. What should be done for it.
However its giving an error in mentioned line that
function argument #1 of type 'flash unsigned char[2]' is incompatible with required parameter of type 'unsigned char'. What should be done for it.
Did you quote the error message correctly? I would expect "required parameter of type 'unsigned char *'"
It looks like the behaviour of a compiler where pointers to constant data in flash and RAM data aren't assignment compatible and need special handling. I'm not familiar with AVR codevision, but I see there's a chapter "4.12 Pointers" in user manual. Essentially you need a separate print function with flash char* argument, or copy the string to RAM before printing it.
Yes FvM you are right, it is 'unsigned char *'. Really it was an issue of compiler. I made changes suggested by alexan. Its working now. Thanx to both of you guys.
How ever could any body of you suggest some changes in the code. Because i am not getting anything on the LCD. Not even cursor blinking. Whether i am dividing 8 bit data in 4 bit properly. GND Pin of LCD is connected to Pin 22 of Atmega8 and VCC pin of LCD to Pin 20 of Atmega8. D4,D5,D6,D7 of LCD to PC0, PC1,PC2,PC3 of Atmega8. R/W pin is grounded.
codevision includes it's own LCD library, is there a reason you want to write your own?
- - - Updated - - -
Note that the codevision library uses assembly for the majority of its functions do it should be faster that a custom library.
Maybe you are trying to write something that occupies less flash?
- - - Updated - - -
It's usually a good idea to check some of the existing LCD libraries and use them as example to write your own or do modifications.
My LCD routine is working fine now. Only issue is 'Print_LCD' function is accepting only string. However i want to use DS1307 RTC now and display time and date on LCD. So made some modifications in the code. Rest of the things are same just I2C and DS1307 library. Here is the code
Code:
while (1)
{
// Place your code here
/* read time from the DS1307 RTC */
rtc_get_time(&h,&m,&s);
time_hr = h;
sprintf(strbuff,"%d",time_hr);
Print_LCD("Welcome");
LCD_Cmd(0xc0);
Print_LCD(strbuff);//////////////////////////////Error//////////////////
};
Now the same error appears as i have mentioned before. I have declared variables time_hr as unsigned char and strbuff[20] as char.
there is no such function as SPRINTI() in codevision, i searched it. Any other option.Am i reading hour value correctly i.e
time_hr=h; is it right. Because i am getting value '0' on LCD. I took original Print_LCD function with 'char *cptr' to display 'strbuff '.
Thanx alexan, I did same. It's working now. I didn't know that we have to set the data in RTC first. Then it gives us the time value. Now its giving right time value.