View previous topic :: View next topic |
Author |
Message |
Core2
Joined: 27 Sep 2008 Posts: 22
|
Problem with i2c_write |
Posted: Sat Sep 27, 2008 1:38 pm |
|
|
Hello everyone,
My 'C' is apparently WAY rustier than I thought. I have an I2C LCD (LCD03) that I'm trying to write to with a PIC18F4620. I did a search for LCD03 and found this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=28853
It seems to do what I'm looking for. I copied & pasted the two files in to my compiler (ver 4.071), saved them then tried to compile them. I keep getting an "Error 66: Previous identifier must be a pointer" referencing this line
Code: | i2c_write(text[i-1]); |
This is located in the LCD_write function in the Header file. It points to the '1' in the statement. I removed the '-1' so that it just reads [i] then I got the same error referring to the 'i' in the code.
I don't understand what this is trying to tell me. Your help will be greatly appreciated.
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Sep 27, 2008 2:03 pm |
|
|
Quote: | I copied & pasted the two files in to my compiler |
1. Post the code that you're trying to compile. The exact code.
2. Post if you're using the CCS IDE or MPLAB. |
|
|
Core2
Joined: 27 Sep 2008 Posts: 22
|
|
Posted: Sat Sep 27, 2008 2:17 pm |
|
|
I'm using CCS compiler PCW V4.071. Here is the main file:
Code: | #include <18F4620.h>
#device *=16 ICD=TRUE
#use delay(clock=20M)
//set up i2c peripheral and use hardware SSP
#use i2c(Master,sda=PIN_C4,scl=PIN_C3,FORCE_HW)
#include <string.h>
#include <LCD03.h>
#fuses HS,BROWNOUT,PUT,NOLVP
unsigned char buffer1[20];
void main()
{
delay_ms(500);
init_LCD();
strcpy(buffer1,"Voltage: ");
LCD_write(buffer1);
while(1)
{ }
} |
Here is the LCD03.h file:
Code: | #include <string.h>
#define lcd_addr 0xC6 //LCD Address
int i, max;
unsigned char buffer[20];
void LCD_write(text)
{ //function to write a string to i2c LCD
i2c_start();
i2c_write(lcd_addr);
max=strlen(text);
for(i=0; i<=max; i++)
{
i2c_write(text[i-1]);
}
i2c_write(0x0D); //carriage return
i2c_stop();
}
void init_LCD()
{ //startup message for LCD Display
i2c_start(); //set i2c to start condition
i2c_write(lcd_addr); //send lcd address
i2c_write(0x00); //write to register 0
i2c_write(0x05); //cursor type: underline
i2c_write(0x0C); //clears screen and sets cursor to home position
strcpy(buffer,"Rover 1.0"); //copies name of project to string
LCD_write(buffer); //writes name of project to LCD
strcpy(buffer,"Started 9/27/08"); //copies start date to string
LCD_write(buffer); //writes string to LCD
delay_ms(1000); //delay to read startup message
i2c_write(0x0C); //clears screen and sets cursor to home position
i2c_stop();
} |
|
|
|
Ttelmah Guest
|
|
Posted: Sat Sep 27, 2008 2:31 pm |
|
|
The text definition, needs a type.
void LCD_write(char * text)
Best Wishes |
|
|
Core2
Joined: 27 Sep 2008 Posts: 22
|
|
Posted: Sat Sep 27, 2008 2:38 pm |
|
|
Thanks! That did the trick. I did mention that I was VERY rusty at this, right?
Thanks again! |
|
|
|